diff options
author | Daniel Mensinger <daniel@mensinger-ka.de> | 2020-06-12 22:03:50 +0200 |
---|---|---|
committer | Nirbheek Chauhan <nirbheek.chauhan@gmail.com> | 2020-06-13 18:50:00 +0000 |
commit | 6c56478ee1e15477b54d92bf25b7b4b1489bfcdb (patch) | |
tree | 91152b2875100d99a00a8728a5dcc795740ed656 /test cases/cmake | |
parent | 3babaaaeecb01ceefb25508783207f1bf7876447 (diff) | |
download | meson-6c56478ee1e15477b54d92bf25b7b4b1489bfcdb.zip meson-6c56478ee1e15477b54d92bf25b7b4b1489bfcdb.tar.gz meson-6c56478ee1e15477b54d92bf25b7b4b1489bfcdb.tar.bz2 |
cmake: fix definitions with interface libraries (fixes #7299)
Diffstat (limited to 'test cases/cmake')
6 files changed, 22 insertions, 0 deletions
diff --git a/test cases/cmake/1 basic/subprojects/cmMod/CMakeLists.txt b/test cases/cmake/1 basic/subprojects/cmMod/CMakeLists.txt index 9798209..9c95636 100644 --- a/test cases/cmake/1 basic/subprojects/cmMod/CMakeLists.txt +++ b/test cases/cmake/1 basic/subprojects/cmMod/CMakeLists.txt @@ -8,5 +8,7 @@ include_directories(${CMAKE_CURRENT_BINARY_DIR}) add_definitions("-DDO_NOTHING_JUST_A_FLAG=1") add_library(cmModLib++ SHARED cmMod.cpp) +target_compile_definitions(cmModLib++ PRIVATE MESON_MAGIC_FLAG=21) +target_compile_definitions(cmModLib++ INTERFACE MESON_MAGIC_FLAG=42) include(GenerateExportHeader) generate_export_header(cmModLib++) diff --git a/test cases/cmake/1 basic/subprojects/cmMod/cmMod.cpp b/test cases/cmake/1 basic/subprojects/cmMod/cmMod.cpp index d3141d5..f4cbea0 100644 --- a/test cases/cmake/1 basic/subprojects/cmMod/cmMod.cpp +++ b/test cases/cmake/1 basic/subprojects/cmMod/cmMod.cpp @@ -2,6 +2,10 @@ using namespace std; +#if MESON_MAGIC_FLAG != 21 +#error "Invalid MESON_MAGIC_FLAG (private)" +#endif + cmModClass::cmModClass(string foo) { str = foo + " World"; } diff --git a/test cases/cmake/1 basic/subprojects/cmMod/cmMod.hpp b/test cases/cmake/1 basic/subprojects/cmMod/cmMod.hpp index 0e6dc04..4445e1f 100644 --- a/test cases/cmake/1 basic/subprojects/cmMod/cmMod.hpp +++ b/test cases/cmake/1 basic/subprojects/cmMod/cmMod.hpp @@ -3,6 +3,10 @@ #include "cmmodlib++_export.h" #include <string> +#if MESON_MAGIC_FLAG != 42 && MESON_MAGIC_FLAG != 21 +#error "Invalid MESON_MAGIC_FLAG" +#endif + class CMMODLIB___EXPORT cmModClass { private: std::string str; diff --git a/test cases/cmake/10 header only/main.cpp b/test cases/cmake/10 header only/main.cpp index 9507961..1417881 100644 --- a/test cases/cmake/10 header only/main.cpp +++ b/test cases/cmake/10 header only/main.cpp @@ -3,8 +3,14 @@ using namespace std; +#define EXPECTED "Hello World compDef 42" + int main(void) { cmModClass obj("Hello"); cout << obj.getStr() << endl; + if (obj.getStr() != EXPECTED) { + cerr << "Expected: '" << EXPECTED << "'" << endl; + return 1; + } return 0; } diff --git a/test cases/cmake/10 header only/subprojects/cmMod/CMakeLists.txt b/test cases/cmake/10 header only/subprojects/cmMod/CMakeLists.txt index f5d9a47..e01b6e2 100644 --- a/test cases/cmake/10 header only/subprojects/cmMod/CMakeLists.txt +++ b/test cases/cmake/10 header only/subprojects/cmMod/CMakeLists.txt @@ -9,3 +9,4 @@ add_library(cmModLib INTERFACE) set_target_properties(cmModLib PROPERTIES INTERFACE_COMPILE_OPTIONS "-DCMAKE_FLAG_MUST_BE_PRESENT") target_include_directories(cmModLib INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}/include") target_compile_definitions(cmModLib INTERFACE -DCMAKE_COMPILER_DEFINE_STR="compDef") +target_compile_definitions(cmModLib INTERFACE MESON_MAGIC_FLAG=42) diff --git a/test cases/cmake/10 header only/subprojects/cmMod/include/cmMod.hpp b/test cases/cmake/10 header only/subprojects/cmMod/include/cmMod.hpp index 7ea72f7..fe01040 100644 --- a/test cases/cmake/10 header only/subprojects/cmMod/include/cmMod.hpp +++ b/test cases/cmake/10 header only/subprojects/cmMod/include/cmMod.hpp @@ -6,6 +6,9 @@ #error "The flag CMAKE_FLAG_MUST_BE_PRESENT was not set" #endif +#define xstr(s) str(s) +#define str(s) #s + class cmModClass { private: std::string str; @@ -13,6 +16,8 @@ class cmModClass { cmModClass(std::string foo) { str = foo + " World "; str += CMAKE_COMPILER_DEFINE_STR; + str += ' '; + str += xstr(MESON_MAGIC_FLAG); } inline std::string getStr() const { return str; } |