tests: Extend cmake test with -Wl,--version-script

This tests that CMake link flags marked as PRIVATE are not propagated
through the generated Meson dependency. -Wl,--version-script is used as
the "poison" here, the build ultimately fails if it appears in the
shared_library() link command.
pull/13429/head
Jonathon Anderson 5 months ago committed by Eli Schwartz
parent 6165db80bb
commit 066cf804bb
  1. 6
      test cases/cmake/2 advanced/main3.cpp
  2. 2
      test cases/cmake/2 advanced/meson.build
  3. 14
      test cases/cmake/2 advanced/slib.cpp
  4. 7
      test cases/cmake/2 advanced/subprojects/cmMod/CMakeLists.txt
  5. 7
      test cases/cmake/2 advanced/subprojects/cmMod/vers.map

@ -0,0 +1,6 @@
extern void slib();
int main() {
slib();
return 0;
}

@ -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)

@ -0,0 +1,14 @@
#include <iostream>
#include <cmMod.hpp>
#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;
}

@ -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)

@ -0,0 +1,7 @@
{
global:
extern "C++" {
cmModClass::*;
};
local: *;
};
Loading…
Cancel
Save