diff --git a/CMakeLists.txt b/CMakeLists.txt index 1c0fdd27..621e28a1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,9 +16,26 @@ file( GLOB BOOST_REGEX_SRC ./src/*.cpp ) add_library( boost_regex ${BOOST_REGEX_SRC} ) add_library( Boost::regex ALIAS boost_regex ) -target_include_directories( boost_regex PUBLIC include ) -target_compile_definitions( boost_regex PUBLIC BOOST_REGEX_NO_LIB) +# Currently, installation isn't supported directly, +# but someone else might install this target from the parent +# CMake script, so lets proactively differentiate between +# the include directory during regular use (BUILD_INTERFACE) +# and after installation +target_include_directories( boost_regex + PUBLIC + $ + $ +) +target_compile_definitions( boost_regex + PUBLIC + # No need for autolink and we don't mangle library name anyway + BOOST_REGEX_NO_LIB + $<$,SHARED_LIBRARY>:BOOST_REGEX_DYN_LINK=1> + $<$,STATIC_LIBRARY>:BOOST_REGEX_STATIC_LINK=1> +) + +# Specify dependencies (including header-only libraries) target_link_libraries( boost_regex PUBLIC Boost::assert