[CMake] combine multiple library into a single one

Emanuele Cannizzaro emanuele.cannizzaro at gmail.com
Sat Jun 21 20:00:42 EDT 2014


Dear Sir/Madame,

I am trying to create a library that it depends on compiler flags.

I can create 4 library that will all together include all the functions 
required, that is 

add_library(amd_di SHARED ${SRC_LIST} ${HEADER_FILES})
target_link_libraries(amd_di m)

add_library(amd_dl SHARED ${SRC_LIST} ${HEADER_FILES})
set_target_properties(amd_dl PROPERTIES COMPILE_FLAGS "-DDLONG=ON")
target_link_libraries(amd_dl m)

add_library(amd_zi SHARED ${SRC_LIST} ${HEADER_FILES})
set_target_properties(amd_zi PROPERTIES COMPILE_FLAGS "-DZLONG=ON")
target_link_libraries(amd_zi m)

add_library(amd_zl SHARED ${SRC_LIST} ${HEADER_FILES})
set_target_properties(amd_zl PROPERTIES COMPILE_FLAGS "-DZLONG=ON -DDLONG=ON")
target_link_libraries(amd_zl m)

Each run will generate different functions thats is foo_di_xxx, foo_dl_xxx and 
so on.

How can I combine the four library into a single one?

target_link_libraries(amd amd_zl amd_zi amd_dl amd_di m)

Thank you in advance.

Regards,
Emanuele



More information about the CMake mailing list