diff options
Diffstat (limited to 'test cases/cmake/12 generator expressions')
5 files changed, 122 insertions, 0 deletions
diff --git a/test cases/cmake/12 generator expressions/main.cpp b/test cases/cmake/12 generator expressions/main.cpp new file mode 100644 index 0000000..9507961 --- /dev/null +++ b/test cases/cmake/12 generator expressions/main.cpp @@ -0,0 +1,10 @@ +#include <iostream> +#include <cmMod.hpp> + +using namespace std; + +int main(void) { + cmModClass obj("Hello"); + cout << obj.getStr() << endl; + return 0; +} diff --git a/test cases/cmake/12 generator expressions/meson.build b/test cases/cmake/12 generator expressions/meson.build new file mode 100644 index 0000000..ca08a3f --- /dev/null +++ b/test cases/cmake/12 generator expressions/meson.build @@ -0,0 +1,12 @@ +project('cmakeSubTest', ['c', 'cpp']) + +cm = import('cmake') + +sub_pro = cm.subproject('cmMod') +sub_dep = sub_pro.dependency('cmModLib') + +assert(sub_pro.target_list() == ['cmModLib'], 'There should be exactly one target') +assert(sub_pro.target_type('cmModLib') == 'header_only', 'Target type should be header_only') + +exe1 = executable('main', ['main.cpp'], dependencies: [sub_dep]) +test('test1', exe1) diff --git a/test cases/cmake/12 generator expressions/subprojects/cmMod/CMakeLists.txt b/test cases/cmake/12 generator expressions/subprojects/cmMod/CMakeLists.txt new file mode 100644 index 0000000..27b3721 --- /dev/null +++ b/test cases/cmake/12 generator expressions/subprojects/cmMod/CMakeLists.txt @@ -0,0 +1,32 @@ +cmake_minimum_required(VERSION 3.5) + +project(cmMod) +set (CMAKE_CXX_STANDARD 14) + +include(GNUInstallDirs) + +add_library(cmModLib INTERFACE) + +target_compile_options(cmModLib + INTERFACE $<$<AND:$<CONFIG:Release>,$<CONFIG:Debug>>:-DCMAKE_FLAG_ERROR_A> # Check discard = false + INTERFACE "-DCMAKE_FLAG_REQUIRED_A" + INTERFACE $<$<AND:1,$<STREQUAL:asd,$<LOWER_CASE:AsD>>,$<NOT:$<EQUAL:4,2>>>:-DCMAKE_FLAG_REQUIRED_B> + INTERFACE $<$<VERSION_LESS:1.2.3,2.1.0>:-DCMAKE_FLAG_REQUIRED_C> + INTERFACE $<IF:$<NOT:$<BOOL:OFF>>,-DCMAKE_TRUE_FLAG,-DCMAKE_FALSE_FLAG> + INTERFACE $<IF:$<TARGET_EXISTS:cmModLib>,-DCMAKE_TGT_EXISTS,-DCMAKE_TGT_NEXISTS> + INTERFACE $<IF:$<TARGET_PROPERTY:IMPORTED_NO_SONAME>,-DCMAKE_PROP1_OK,-DCMAKE_PROP1_ERROR> + INTERFACE $<IF:$<TARGET_PROPERTY:cmModLib,IMPORT_SUFFIX>,-DCMAKE_PROP2_ERROR,-DCMAKE_PROP2_OK> +) + +target_include_directories(cmModLib INTERFACE + $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> + $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}> +) + +set_target_properties(cmModLib + PROPERTIES + IMPORTED_NO_SONAME 1 + IMPORT_SUFFIX 0 +) + +target_compile_definitions(cmModLib INTERFACE -DCMAKE_COMPILER_DEFINE_STR="compDef") diff --git a/test cases/cmake/12 generator expressions/subprojects/cmMod/include/cmMod.hpp b/test cases/cmake/12 generator expressions/subprojects/cmMod/include/cmMod.hpp new file mode 100644 index 0000000..416e5bb --- /dev/null +++ b/test cases/cmake/12 generator expressions/subprojects/cmMod/include/cmMod.hpp @@ -0,0 +1,63 @@ +#pragma once + +#include <string> + +#ifndef CMAKE_FLAG_REQUIRED_A +#error "The flag CMAKE_FLAG_REQUIRED_A was not set" +#endif + +#ifndef CMAKE_FLAG_REQUIRED_B +#error "The flag CMAKE_FLAG_REQUIRED_B was not set" +#endif + +#ifndef CMAKE_FLAG_REQUIRED_C +#error "The flag CMAKE_FLAG_REQUIRED_C was not set" +#endif + +#ifdef CMAKE_FLAG_ERROR_A +#error "The flag CMAKE_FLAG_ERROR_A was set" +#endif + +#ifndef CMAKE_TRUE_FLAG +#error "The flag CMAKE_TRUE_FLAG was not set" +#endif + +#ifdef CMAKE_FALSE_FLAG +#error "The flag CMAKE_FALSE_FLAG was set" +#endif + +#ifndef CMAKE_TGT_EXISTS +#error "The flag CMAKE_TGT_EXISTS was not set" +#endif + +#ifdef CMAKE_TGT_NEXISTS +#error "The flag CMAKE_TGT_NEXISTS was set" +#endif + +#ifndef CMAKE_PROP1_OK +#error "The flag CMAKE_PROP1_OK was not set" +#endif + +#ifdef CMAKE_PROP1_ERROR +#error "The flag CMAKE_PROP1_ERROR was set" +#endif + +#ifndef CMAKE_PROP2_OK +#error "The flag CMAKE_PROP2_OK was not set" +#endif + +#ifdef CMAKE_PROP2_ERROR +#error "The flag CMAKE_PROP2_ERROR was set" +#endif + +class cmModClass { + private: + std::string str; + public: + cmModClass(std::string foo) { + str = foo + " World "; + str += CMAKE_COMPILER_DEFINE_STR; + } + + inline std::string getStr() const { return str; } +}; diff --git a/test cases/cmake/12 generator expressions/test.json b/test cases/cmake/12 generator expressions/test.json new file mode 100644 index 0000000..faf1ff8 --- /dev/null +++ b/test cases/cmake/12 generator expressions/test.json @@ -0,0 +1,5 @@ +{ + "tools": { + "cmake": ">=3.19" + } +} |