Skip to content

Commit 0d42c2d

Browse files
Add the possibility to use a system wide installation of tl-optional (#207)
* Fix typo in tl-optional folder name * Add the possibility to use a system-wide installation of tl-optional * Bump tl-optional to the latest version (1.0.x) * Update CMakeLists.txt
1 parent 5d1297b commit 0d42c2d

File tree

5 files changed

+362
-577
lines changed

5 files changed

+362
-577
lines changed

CMakeLists.txt

+17-5
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,18 @@ add_library(${PROJECT_NAME} INTERFACE)
8080
# INTERFACE_COMPILE_FEATURES cxx_std_11
8181
#)
8282

83+
option(USE_SYSTEM_WIDE_TL_OPTIONAL "Use a system wide installation of tl-optional" OFF)
84+
85+
find_package(tl-optional 1.0.0 QUIET)
86+
if(USE_SYSTEM_WIDE_TL_OPTIONAL AND NOT tl-optional_FOUND)
87+
message(FATAL_ERROR "Could not find required package tl-optional")
88+
endif()
89+
8390
target_include_directories(${PROJECT_NAME} INTERFACE
84-
"$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include;${PROJECT_SOURCE_DIR}/external/lt>"
91+
"$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include$<$<NOT:$<BOOL:${tl-optional_FOUND}>>:;${PROJECT_SOURCE_DIR}/external/tl>>"
8592
"$<INSTALL_INTERFACE:include>"
8693
)
94+
target_link_libraries(${PROJECT_NAME} INTERFACE "$<$<BOOL:${tl-optional_FOUND}>:tl::optional>")
8795

8896
# Add Eigen interface dependency, depending on available cmake info
8997
if(TARGET Eigen3::Eigen)
@@ -155,10 +163,14 @@ install(
155163
)
156164

157165
# Headers:
158-
install(
159-
FILES "${PROJECT_SOURCE_DIR}/external/lt/lt/optional.hpp"
160-
DESTINATION include/lt
161-
)
166+
167+
# if tl-optional is not found manif will install its own version
168+
if(NOT tl-optional_FOUND)
169+
install(
170+
FILES "${PROJECT_SOURCE_DIR}/external/tl/tl/optional.hpp"
171+
DESTINATION include/tl
172+
)
173+
endif()
162174

163175
install(
164176
DIRECTORY "${PROJECT_SOURCE_DIR}/include/${PROJECT_NAME}"

0 commit comments

Comments
 (0)