Skip to content

Commit c6d1c7f

Browse files
authored
Fix build with CMake (#103)
1 parent 4105c3a commit c6d1c7f

File tree

1 file changed

+31
-10
lines changed

1 file changed

+31
-10
lines changed

CMakeLists.txt

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@ project(boost_dll VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX)
1010

1111
option(BOOST_DLL_USE_STD_FS "Use std::filesystem instead of Boost.Filesystem" OFF)
1212

13+
# Base library
14+
1315
add_library(boost_dll_base INTERFACE)
16+
add_library(Boost::dll_base ALIAS boost_dll_base)
1417
target_include_directories(boost_dll_base INTERFACE include)
1518
target_link_libraries(boost_dll_base
1619
INTERFACE
@@ -25,35 +28,53 @@ target_link_libraries(boost_dll_base
2528
${CMAKE_DL_LIBS}
2629
)
2730

31+
# Library with std::filesystem
2832

2933
add_library(boost_dll_std_fs INTERFACE)
30-
target_link_libraries(boost_dll_std_fs
31-
INTERFACE
32-
boost_dll_base
33-
)
34+
add_library(Boost::dll_std_fs ALIAS boost_dll_std_fs)
35+
target_include_directories(boost_dll_std_fs INTERFACE include)
36+
target_link_libraries(boost_dll_std_fs INTERFACE Boost::dll_base)
3437
target_compile_definitions(boost_dll_std_fs INTERFACE BOOST_DLL_USE_STD_FS)
3538
target_compile_features(boost_dll_std_fs INTERFACE cxx_std_17)
3639

40+
# Library with Boost.Filesystem
41+
3742
add_library(boost_dll_boost_fs INTERFACE)
43+
add_library(Boost::dll_boost_fs ALIAS boost_dll_boost_fs)
44+
target_include_directories(boost_dll_boost_fs INTERFACE include)
3845
target_link_libraries(boost_dll_boost_fs
3946
INTERFACE
40-
boost_dll_base
47+
Boost::dll_base # Internal dependency
4148
Boost::filesystem
4249
)
4350

51+
# Detault library
4452

4553
add_library(boost_dll INTERFACE)
46-
if(BOOST_DLL_USE_STD_FS)
47-
target_link_libraries(boost_dll INTERFACE boost_dll_std_fs)
54+
add_library(Boost::dll ALIAS boost_dll)
55+
target_include_directories(boost_dll INTERFACE include)
56+
if (BOOST_DLL_USE_STD_FS)
57+
target_link_libraries(boost_dll INTERFACE Boost::dll_std_fs)
4858
else()
49-
target_link_libraries(boost_dll INTERFACE boost_dll_boost_fs)
59+
target_link_libraries(boost_dll INTERFACE Boost::dll_boost_fs)
5060
endif()
5161

52-
add_library(Boost::dll ALIAS boost_dll)
62+
if (BOOST_SUPERPROJECT_VERSION AND NOT CMAKE_VERSION VERSION_LESS 3.13)
63+
boost_install(
64+
TARGETS
65+
boost_dll
66+
boost_dll_base
67+
boost_dll_std_fs
68+
boost_dll_boost_fs
69+
VERSION
70+
"${BOOST_SUPERPROJECT_VERSION}"
71+
HEADER_DIRECTORY
72+
include
73+
)
74+
endif()
5375

5476
if(BUILD_TESTING AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/test/CMakeLists.txt")
5577

5678
add_subdirectory(test)
5779

5880
endif()
59-

0 commit comments

Comments
 (0)