vcpkg/ports/dv-processing/vcpkg-build.patch
jureviciusr 82601c4368
[dv-processing] Add New port for dv processing (#25273)
* New port for dv-processing library

* formatting manifest

* Version update in manifest

* Adding to the versioning system

* Better compatibility for compiler checking when installing

* Version update

* Not using archive release anymore; cli11 is now a vcpkg dependency; cmakemod cloned and copied to the correct directory

* Version update

Co-authored-by: Rokas Jurevicius <rokas.jurevicius@inivation.com>
2022-06-29 23:09:44 -07:00

85 lines
3.1 KiB
Diff

diff --git a/CMakeLists.txt b/CMakeLists.txt
index c7775b5..acf6208 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -27,11 +27,15 @@ IF(Git_FOUND AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/.git")
ENDIF()
ENDIF()
+OPTION(BUILD_CONFIG_VCPKG "Set build environment compatible with VCPKG" OFF)
+
# Basic setup, useful variables, see docs.
SET(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmakemod ${CMAKE_MODULE_PATH})
SET(ENABLE_ALL_WARNINGS ON CACHE BOOL "Turn on all warnings for build" FORCE)
INCLUDE(inivation-setup)
+# Skip compiler compatibility checks when doing the VCPKG build
+if(NOT BUILD_CONFIG_VCPKG)
# Compiler compatibility testing starts GCC has to be at least version 10
IF(CC_GCC AND ${CMAKE_CXX_COMPILER_VERSION} VERSION_LESS "10.0.0")
MESSAGE(
@@ -56,6 +60,7 @@ IF(NOT CC_GCC AND NOT CC_GCC)
)
ENDIF()
# Compiler compatibility testing ends
+ENDIF()
# Boost support. Search in extra directory for custom version.
IF(EXISTS /opt/inivation/boost/)
@@ -87,7 +92,7 @@ CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}.pc.in ${CMAKE_CURRENT
INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
# Cmake find_package() support.
-IF(CC_MSVC)
+IF(BUILD_CONFIG_VCPKG)
SET(CMAKE_EXPORT_DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/${PROJECT_NAME})
ELSE()
SET(CMAKE_EXPORT_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME})
@@ -103,8 +108,13 @@ INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config.cmake
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake
${CMAKE_CURRENT_SOURCE_DIR}/cmakemod/inivation-setup.cmake DESTINATION ${CMAKE_EXPORT_DESTINATION})
-# External libraries to build
-ADD_SUBDIRECTORY(tests/external/cli11)
+IF (BUILD_CONFIG_VCPKG)
+ # Find CLI11 as an installed package
+ FIND_PACKAGE(CLI11 CONFIG REQUIRED)
+ELSE()
+ # External CLI11 checked-out as a submodule
+ ADD_SUBDIRECTORY(tests/external/cli11)
+ENDIF()
# Install header files.
ADD_SUBDIRECTORY(include)
diff --git a/dv-processing-config.cmake.in b/dv-processing-config.cmake.in
index 4dbf635..5557dd2 100644
--- a/dv-processing-config.cmake.in
+++ b/dv-processing-config.cmake.in
@@ -53,10 +53,9 @@ CHECK_REQUIRED_COMPONENTS(dv-processing)
# properly.
INCLUDE(@PACKAGE_CMAKE_EXPORT_DESTINATION@/inivation-setup.cmake)
-# MSVC/VCPKG finds this differently.
-IF(CC_MSVC)
- FIND_PACKAGE(lz4 CONFIG REQUIRED)
-ENDIF()
+# MSVC/VCPKG finds this differently, try to find it quietly, so it does not complain on non-vcpkg installations
+# and find the package correctly when used with VCPKG.
+FIND_PACKAGE(lz4 CONFIG QUIET)
# Compiler compatibility testing starts GCC has to be at least version 10
IF(CC_GCC AND ${CMAKE_CXX_COMPILER_VERSION} VERSION_LESS "10.0.0")
diff --git a/include/dv-processing/CMakeLists.txt b/include/dv-processing/CMakeLists.txt
index b83f4e4..621b3f2 100644
--- a/include/dv-processing/CMakeLists.txt
+++ b/include/dv-processing/CMakeLists.txt
@@ -23,7 +23,7 @@ IF(CC_MSVC)
ENDIF()
# Compression support
-IF(CC_MSVC)
+IF(BUILD_CONFIG_VCPKG)
FIND_PACKAGE(lz4 CONFIG REQUIRED)
TARGET_LINK_LIBRARIES(processing INTERFACE lz4::lz4)
ELSE()