[CMake] How to hundle gcc link options(like whole-archive, --allow-multiple-definition) in CMake?

Chaos Zhang zcsd2012 at gmail.com
Mon May 30 08:35:48 EDT 2016


Hi, all,

Thanks for taking your time to review my email. I have a demo project and
it's structure like as below:

top_dir
    CMakeLists.txt
    sub_dir1
        CMakeLists.txt
    sub_dir2
        CMakeLists.txt

top_dir/sub_dir1/CMakeLists.txt used to build `lib1` by using
`add_library(lib1 ...)`, 
top_dir/sub_dir2/CMakeLists.txt used to build `exe1` with linking lib1 by
`target_link_library(exe1 lib1)`. 
And the content of top_dir/CMakeLists.txt is as below:

add_subdirectory(sub_dir2)
add_subdirectory(sub_dir1)

Normally, when build target exe1, cmake will check dependency so `lib1` will
be built before building exe1. The problem is I am transfering an existed
makefile project into CMake, and there are many gcc link options, like
"whole-archive ... no-whole-archive, allow-mutiple-definition", if use like
`target_link_library(exe1 "-Wl, --whole-archive ../sub_dir1/liblib1.a
--no-whole-archive")`(The form like this, and this may not work, it just a
e.g.), cmake seem don't built `lib1` any more. Is there any way i can use
target_link_library like `target_link_library(exe1 "-Wl, --whole-archive
../sub_dir1/liblib1.a")` and cmake link dependency checking still work, or
other way i can transfer these gcc link options into cmake?

Thanks a lot,
Chao



--
View this message in context: http://cmake.3232098.n2.nabble.com/How-to-hundle-gcc-link-options-like-whole-archive-allow-multiple-definition-in-CMake-tp7593563.html
Sent from the CMake mailing list archive at Nabble.com.


More information about the CMake mailing list