Bundle c++utilities correctly
* Use the c++utilities source directory for includes rather than the locations where headers are goint to be installed * Call find_package for c++utilities only once
This commit is contained in:
parent
d5144d8e75
commit
19cab9c791
|
@ -23,11 +23,33 @@ enable_testing()
|
||||||
set(BUNDLED_CPP_UTILITIES_PATH OFF CACHE PATH "specifies the (relative) path to the c++utilities sources for building it together with ${META_PROJECT_NAME}")
|
set(BUNDLED_CPP_UTILITIES_PATH OFF CACHE PATH "specifies the (relative) path to the c++utilities sources for building it together with ${META_PROJECT_NAME}")
|
||||||
if(NOT BUNDLED_CPP_UTILITIES_PATH)
|
if(NOT BUNDLED_CPP_UTILITIES_PATH)
|
||||||
message(STATUS "Using system c++utilities")
|
message(STATUS "Using system c++utilities")
|
||||||
elseif(IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/${BUNDLED_CPP_UTILITIES_PATH}" OR IS_DIRECTORY "${BUNDLED_CPP_UTILITIES_PATH}")
|
|
||||||
add_subdirectory("${BUNDLED_CPP_UTILITIES_PATH}" c++utilities)
|
|
||||||
list(APPEND CMAKE_MODULE_PATH ${CPP_UTILITIES_SOURCE_DIR}/cmake/modules)
|
|
||||||
else()
|
else()
|
||||||
message(FATAL_ERROR "Specified directory for c++utilities sources \"${BUNDLED_CPP_UTILITIES_PATH}\" does not exist.")
|
# check whether bundled c++utilities actually exists
|
||||||
|
if(IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/${BUNDLED_CPP_UTILITIES_PATH}")
|
||||||
|
# treat the specified path as relative to the current source dir
|
||||||
|
set(c++utilities_DIR "${CMAKE_CURRENT_SOURCE_DIR}/${BUNDLED_CPP_UTILITIES_PATH}")
|
||||||
|
elseif(IS_DIRECTORY "${BUNDLED_CPP_UTILITIES_PATH}")
|
||||||
|
# treat the specified path as absolute
|
||||||
|
set(c++utilities_DIR "${BUNDLED_CPP_UTILITIES_PATH}")
|
||||||
|
else()
|
||||||
|
# consider the specified path invalid
|
||||||
|
set(c++utilities_DIR "")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(c++utilities_DIR)
|
||||||
|
add_subdirectory("${BUNDLED_CPP_UTILITIES_PATH}" c++utilities)
|
||||||
|
list(APPEND CMAKE_MODULE_PATH "${CPP_UTILITIES_SOURCE_DIR}/cmake/modules")
|
||||||
|
else()
|
||||||
|
message(FATAL_ERROR "Specified directory for c++utilities sources \"${BUNDLED_CPP_UTILITIES_PATH}\" does not exist.")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# find c++utilities
|
||||||
|
find_package(c++utilities 4.12.0 REQUIRED)
|
||||||
|
|
||||||
|
# use the source directory of c++utilities for includes (rather than the location where headers are going to be installed)
|
||||||
|
if(BUNDLED_CPP_UTILITIES_PATH)
|
||||||
|
set(CPP_UTILITIES_INCLUDE_DIRS "${CPP_UTILITIES_SOURCE_DIR}/..")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# add header-only library containing JsonSerializable and helper for using RapidJSON
|
# add header-only library containing JsonSerializable and helper for using RapidJSON
|
||||||
|
|
|
@ -34,8 +34,7 @@ set(TEST_SRC_FILES
|
||||||
tests/jsongenerator.cpp
|
tests/jsongenerator.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
# find c++utilities and link against the library
|
# link against c++utilities
|
||||||
find_package(c++utilities 4.12.0 REQUIRED)
|
|
||||||
use_cpp_utilities()
|
use_cpp_utilities()
|
||||||
|
|
||||||
# find Clang for LibTooling; adding clangTooling should be sufficient as it pulls all transitive dependencies
|
# find Clang for LibTooling; adding clangTooling should be sufficient as it pulls all transitive dependencies
|
||||||
|
|
|
@ -28,11 +28,9 @@ set(DOC_FILES
|
||||||
README.md
|
README.md
|
||||||
)
|
)
|
||||||
|
|
||||||
# find c++utilities, but only add the include dirs because we're not depending on the actual library
|
# add (only) the include dirs for c++utilities because we're not depending on the actual library
|
||||||
find_package(c++utilities 4.11.0 REQUIRED)
|
list(APPEND PUBLIC_SHARED_INCLUDE_DIRS "${CPP_UTILITIES_INCLUDE_DIRS}")
|
||||||
list(APPEND PUBLIC_SHARED_INCLUDE_DIRS ${CPP_UTILITIES_INCLUDE_DIRS})
|
list(APPEND PUBLIC_STATIC_INCLUDE_DIRS "${CPP_UTILITIES_INCLUDE_DIRS}")
|
||||||
list(APPEND PUBLIC_STATIC_INCLUDE_DIRS ${CPP_UTILITIES_INCLUDE_DIRS})
|
|
||||||
list(APPEND CMAKE_MODULE_PATH ${CPP_UTILITIES_MODULE_DIRS})
|
|
||||||
|
|
||||||
# find RapidJSON, also add only the include dirs because RapidJSON is a header-only library
|
# find RapidJSON, also add only the include dirs because RapidJSON is a header-only library
|
||||||
find_package(RapidJSON)
|
find_package(RapidJSON)
|
||||||
|
|
Loading…
Reference in New Issue