diff --git a/test cases/cmake/2 advanced/main3.cpp b/test cases/cmake/2 advanced/main3.cpp new file mode 100644 index 000000000..a82c9bd1d --- /dev/null +++ b/test cases/cmake/2 advanced/main3.cpp @@ -0,0 +1,6 @@ +extern void slib(); + +int main() { + slib(); + return 0; +} diff --git a/test cases/cmake/2 advanced/meson.build b/test cases/cmake/2 advanced/meson.build index b301bfe42..39da0c6ad 100644 --- a/test cases/cmake/2 advanced/meson.build +++ b/test cases/cmake/2 advanced/meson.build @@ -15,6 +15,8 @@ sub_sta = sub_pro.dependency('cmModLibStatic') # Build some files exe1 = executable('main1', ['main.cpp'], dependencies: [sub_dep]) exe2 = executable('main2', ['main.cpp'], dependencies: [sub_sta]) +slib = shared_library('slib', ['slib.cpp'], dependencies: [sub_dep]) +exe3 = executable('main3', ['main3.cpp'], link_with: slib) test('test1', exe1) test('test2', exe2) diff --git a/test cases/cmake/2 advanced/slib.cpp b/test cases/cmake/2 advanced/slib.cpp new file mode 100644 index 000000000..a3395e5e1 --- /dev/null +++ b/test cases/cmake/2 advanced/slib.cpp @@ -0,0 +1,14 @@ +#include +#include +#include "config.h" + +#if CONFIG_OPT != 42 +#error "Invalid value of CONFIG_OPT" +#endif + +using namespace std; + +void slib(void) { + cmModClass obj("Hello from lib"); + cout << obj.getStr() << endl; +} diff --git a/test cases/cmake/2 advanced/subprojects/cmMod/CMakeLists.txt b/test cases/cmake/2 advanced/subprojects/cmMod/CMakeLists.txt index 075011749..7af9e6b97 100644 --- a/test cases/cmake/2 advanced/subprojects/cmMod/CMakeLists.txt +++ b/test cases/cmake/2 advanced/subprojects/cmMod/CMakeLists.txt @@ -17,6 +17,13 @@ generate_export_header(cmModLib) set_target_properties(cmModLib PROPERTIES VERSION 1.0.1) +include(CheckLinkerFlag) +check_linker_flag(CXX "-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/vers.map" HAS_VER_SCRIPT) +if(HAS_VER_SCRIPT) + target_link_options(cmModLib PRIVATE + "-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/vers.map") +endif() + add_executable(testEXE main.cpp "${CMAKE_CURRENT_BINARY_DIR}/config.h") target_link_libraries(cmModLib ZLIB::ZLIB) diff --git a/test cases/cmake/2 advanced/subprojects/cmMod/vers.map b/test cases/cmake/2 advanced/subprojects/cmMod/vers.map new file mode 100644 index 000000000..316d05254 --- /dev/null +++ b/test cases/cmake/2 advanced/subprojects/cmMod/vers.map @@ -0,0 +1,7 @@ +{ + global: + extern "C++" { + cmModClass::*; + }; + local: *; +};