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?