cmake link libraries to a static lib, substitue all $ sign to ~
- User
cmake link libraries to a static lib, substitue all $ sign to ~
- Assistant
To link libraries to a static lib in CMake while substituting all $ signs with ~, you can use the following code:
codecmake_minimum_required(VERSION 3.0) project(my_project) set(CMAKE_CXX_STANDARD 11) set(MY_STATIC_LIB my_static_lib) set(MY_LIBS lib1 lib2 lib3 ) foreach(MY_LIB ${MY_LIBS}) string(REPLACE "$" "~" MY_LIB_MODIFIED ${MY_LIB}) add_library(${MY_LIB_MODIFIED} SHARED IMPORTED) set_property(TARGET ${MY_LIB_MODIFIED} PROPERTY IMPORTED_LOCATION ${MY_LIB_LOCATION}) endforeach() add_library(${MY_STATIC_LIB} STATIC my_static_lib.cpp) target_link_libraries(${MY_STATIC_LIB} ${MY_LIBS})