Skip to content

Commit d215acf

Browse files
committed
cmake: link Boost libraries to specific targets
According to make documentation, the `target_link_libraries()` command should be preferred whenever possible. Related: csutils#196
1 parent e482bd7 commit d215acf

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

src/CMakeLists.txt

+12-13
Original file line numberDiff line numberDiff line change
@@ -55,25 +55,21 @@ endif()
5555
add_subdirectory(lib)
5656
include_directories(lib)
5757

58-
# link cslib.a and boost libraries
59-
link_libraries(cs
60-
${Boost_FILESYSTEM_LIBRARY}
61-
${Boost_PROGRAM_OPTIONS_LIBRARY}
62-
${Boost_REGEX_LIBRARY})
63-
6458
# the list of executables
6559
add_executable(csdiff csdiff.cc)
6660
add_executable(csgrep csgrep.cc)
6761
add_executable(cshtml cshtml.cc)
6862
add_executable(cslinker cslinker.cc)
6963
add_executable(cssort cssort.cc)
70-
target_link_libraries(cshtml
71-
${Boost_SYSTEM_LIBRARY})
72-
73-
# experimental
7464
add_executable(cstrans-df-run cstrans-df-run.cc)
75-
target_link_libraries(cstrans-df-run
76-
${Boost_SYSTEM_LIBRARY})
65+
66+
# link cslib.a and boost libraries
67+
foreach(tgt csdiff csgrep cshtml cslinker cssort cstrans-df-run)
68+
target_link_libraries(${tgt} cs
69+
${Boost_FILESYSTEM_LIBRARY}
70+
${Boost_PROGRAM_OPTIONS_LIBRARY}
71+
${Boost_REGEX_LIBRARY})
72+
endforeach()
7773

7874
# declare what 'make install' should install
7975
include(GNUInstallDirs)
@@ -111,7 +107,10 @@ macro(build_pycsdiff version)
111107

112108
add_library(pycsdiff_py${version} MODULE pycsdiff.cc)
113109
target_link_libraries(pycsdiff_py${version}
114-
PRIVATE ${Boost_PYTHON${PYTHON_VERSION_SUFFIX}_LIBRARY}
110+
PRIVATE cs
111+
${Boost_FILESYSTEM_LIBRARY}
112+
${Boost_REGEX_LIBRARY}
113+
${Boost_PYTHON${PYTHON_VERSION_SUFFIX}_LIBRARY}
115114
Python${version}::Module)
116115

117116
# set correct name so that `python -c 'import pycsdiff' works`

0 commit comments

Comments
 (0)