Commit c3be5dc6 by kmurray

CMake: Ensure abc executable depends on libabc

This ensures that libabc is built only once.

Previously the code for libabc was being built twice: once for the
abc executable target, and again for the libabc target.
parent a2d59be3
...@@ -88,15 +88,17 @@ function(abc_properties target visibility) ...@@ -88,15 +88,17 @@ function(abc_properties target visibility)
target_link_libraries(${target} ${visibility} ${ABC_LIBS}) target_link_libraries(${target} ${visibility} ${ABC_LIBS})
endfunction() endfunction()
add_executable(abc ${ABC_SRC}) set(ABC_MAIN_SRC src/base/main/main.c)
abc_properties(abc PRIVATE) list(REMOVE_ITEM ABC_SRC ${ABC_MAIN_SRC})
list(REMOVE_ITEM ABC_SRC src/base/main/main.c)
add_library(libabc EXCLUDE_FROM_ALL ${ABC_SRC}) add_library(libabc EXCLUDE_FROM_ALL ${ABC_SRC})
abc_properties(libabc PUBLIC) abc_properties(libabc PUBLIC)
set_property(TARGET libabc PROPERTY OUTPUT_NAME abc) set_property(TARGET libabc PROPERTY OUTPUT_NAME abc)
add_executable(abc ${ABC_MAIN_SRC})
target_link_libraries(abc PRIVATE libabc)
abc_properties(abc PRIVATE)
add_library(libabc-pic EXCLUDE_FROM_ALL ${ABC_SRC}) add_library(libabc-pic EXCLUDE_FROM_ALL ${ABC_SRC})
abc_properties(libabc-pic PUBLIC) abc_properties(libabc-pic PUBLIC)
set_property(TARGET libabc-pic PROPERTY POSITION_INDEPENDENT_CODE ON) set_property(TARGET libabc-pic PROPERTY POSITION_INDEPENDENT_CODE ON)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment