The main objective with this question is to write an CMakeLists.txt
to generate a dynamic library, "containing/linked" a static library.
Let me create the scenario:
- My C++ code is written in
mycode.cpp
- In
mycode.cpp
, I call some functions fromlibthirdparty.a
(static library) - I want to generate
libmylib.so
(shared library) to be dynamically linked by others libmylib.so
must to "contain"libthirdparty.a
My attempt to write this script is at the lines bellow:
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Werror -m64 -fPIC ")
add_executable(myapp mycode.cpp)
target_link_libraries(myapp thirdparty)
add_library(mylib SHARED myapp)
But of course this is not working and I would like some help to write it correctly.