Skip to content

Commit 04736ac

Browse files
committed
cmake: avoid duplicated compilation of common code base
1 parent 36db2d8 commit 04736ac

1 file changed

Lines changed: 9 additions & 6 deletions

File tree

src/CMakeLists.txt

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,14 @@ add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/csclng++.c
3434
add_definitions(-iquote ${CMAKE_CURRENT_SOURCE_DIR})
3535
add_definitions(-iquote ${CMAKE_SOURCE_DIR})
3636

37+
# compile the common code base only once (as a static library)
38+
add_library(cswrap STATIC cswrap-core.c ../cswrap/src/cswrap-util.c)
39+
link_libraries(cswrap)
40+
3741
# compile and install executables
38-
add_executable(cscppc cscppc.c cswrap-core.c ../cswrap/src/cswrap-util.c)
39-
add_executable(csclng csclng.c cswrap-core.c ../cswrap/src/cswrap-util.c)
40-
add_executable(csgcca csgcca.c cswrap-core.c ../cswrap/src/cswrap-util.c)
41-
add_executable(csclng++ ${CMAKE_CURRENT_BINARY_DIR}/csclng++.c
42-
cswrap-core.c ../cswrap/src/cswrap-util.c)
43-
add_executable(csmatch csmatch.c cswrap-core.c ../cswrap/src/cswrap-util.c)
42+
add_executable(cscppc cscppc.c)
43+
add_executable(csclng csclng.c)
44+
add_executable(csclng++ ${CMAKE_CURRENT_BINARY_DIR}/csclng++.c)
45+
add_executable(csgcca csgcca.c)
46+
add_executable(csmatch csmatch.c)
4447
install(TARGETS cscppc csclng csclng++ csgcca csmatch DESTINATION bin)

0 commit comments

Comments
 (0)