diff options
author | Daniel Mensinger <daniel@mensinger-ka.de> | 2019-04-19 10:14:03 +0200 |
---|---|---|
committer | Daniel Mensinger <daniel@mensinger-ka.de> | 2019-06-06 18:27:03 +0200 |
commit | 7c4f46b65c6d9d8bf71c0eca3c75e5f8b5f73617 (patch) | |
tree | c41604632ede2b51c02fab1ba07b35dace4e8a5d /test cases/cmake | |
parent | 4279255401a2fe8b24c20f49f4e5be0f8a6d56db (diff) | |
download | meson-7c4f46b65c6d9d8bf71c0eca3c75e5f8b5f73617.zip meson-7c4f46b65c6d9d8bf71c0eca3c75e5f8b5f73617.tar.gz meson-7c4f46b65c6d9d8bf71c0eca3c75e5f8b5f73617.tar.bz2 |
cmake: Fixed test cases for windows
Diffstat (limited to 'test cases/cmake')
34 files changed, 177 insertions, 12 deletions
diff --git a/test cases/cmake/1 basic/meson.build b/test cases/cmake/1 basic/meson.build index de54cce..eaa1e7a 100644 --- a/test cases/cmake/1 basic/meson.build +++ b/test cases/cmake/1 basic/meson.build @@ -1,4 +1,4 @@ -project('cmakeSubTest', ['cpp']) +project('cmakeSubTest', ['c', 'cpp']) sub_pro = subproject('cmMod', method: 'cmake') sub_dep = sub_pro.get_variable('cmModLib_dep') diff --git a/test cases/cmake/1 basic/subprojects/cmMod/CMakeLists.txt b/test cases/cmake/1 basic/subprojects/cmMod/CMakeLists.txt index f27f636..7a9538b 100644 --- a/test cases/cmake/1 basic/subprojects/cmMod/CMakeLists.txt +++ b/test cases/cmake/1 basic/subprojects/cmMod/CMakeLists.txt @@ -3,4 +3,8 @@ cmake_minimum_required(VERSION 3.5) project(cmMod) set (CMAKE_CXX_STANDARD 14) +add_definitions("-DDO_NOTHING_JUST_A_FLAG=1") + add_library(cmModLib SHARED cmMod.cpp) +include(GenerateExportHeader) +generate_export_header(cmModLib) diff --git a/test cases/cmake/1 basic/subprojects/cmMod/cmMod.hpp b/test cases/cmake/1 basic/subprojects/cmMod/cmMod.hpp index 29938dc..52f576b 100644 --- a/test cases/cmake/1 basic/subprojects/cmMod/cmMod.hpp +++ b/test cases/cmake/1 basic/subprojects/cmMod/cmMod.hpp @@ -1,8 +1,9 @@ #pragma once #include <string> +#include "cmmodlib_export.h" -class cmModClass { +class CMMODLIB_EXPORT cmModClass { private: std::string str; public: diff --git a/test cases/cmake/2 advanced/meson.build b/test cases/cmake/2 advanced/meson.build index b3acc97..5f949f4 100644 --- a/test cases/cmake/2 advanced/meson.build +++ b/test cases/cmake/2 advanced/meson.build @@ -1,4 +1,9 @@ -project('cmakeSubTest_advanced', ['cpp']) +project('cmakeSubTest_advanced', ['c', 'cpp']) + +dep_test = dependency('ZLIB', method: 'cmake', required: false) +if not dep_test.found() + error('MESON_SKIP_TEST: zlib is not installed') +endif # Test the "normal" subproject call sub_pro = subproject('cmMod') diff --git a/test cases/cmake/2 advanced/subprojects/cmMod/CMakeLists.txt b/test cases/cmake/2 advanced/subprojects/cmMod/CMakeLists.txt index 3f33e4d..14908a3 100644 --- a/test cases/cmake/2 advanced/subprojects/cmMod/CMakeLists.txt +++ b/test cases/cmake/2 advanced/subprojects/cmMod/CMakeLists.txt @@ -11,6 +11,9 @@ set(CONFIG_OPT 42) configure_file("config.h.in" "${CMAKE_CURRENT_BINARY_DIR}/config.h" @ONLY) add_library(cmModLib SHARED lib/cmMod.cpp) +include(GenerateExportHeader) +generate_export_header(cmModLib) + add_executable(testEXE main.cpp) target_link_libraries(cmModLib ZLIB::ZLIB) diff --git a/test cases/cmake/2 advanced/subprojects/cmMod/lib/cmMod.hpp b/test cases/cmake/2 advanced/subprojects/cmMod/lib/cmMod.hpp index 29938dc..52f576b 100644 --- a/test cases/cmake/2 advanced/subprojects/cmMod/lib/cmMod.hpp +++ b/test cases/cmake/2 advanced/subprojects/cmMod/lib/cmMod.hpp @@ -1,8 +1,9 @@ #pragma once #include <string> +#include "cmmodlib_export.h" -class cmModClass { +class CMMODLIB_EXPORT cmModClass { private: std::string str; public: diff --git a/test cases/cmake/3 advanced no dep/main.cpp b/test cases/cmake/3 advanced no dep/main.cpp new file mode 100644 index 0000000..6cc4c0c --- /dev/null +++ b/test cases/cmake/3 advanced no dep/main.cpp @@ -0,0 +1,15 @@ +#include <iostream> +#include <cmMod.hpp> +#include "config.h" + +#if CONFIG_OPT != 42 +#error "Invalid value of CONFIG_OPT" +#endif + +using namespace std; + +int main() { + cmModClass obj("Hello"); + cout << obj.getStr() << endl; + return 0; +} diff --git a/test cases/cmake/3 advanced no dep/meson.build b/test cases/cmake/3 advanced no dep/meson.build new file mode 100644 index 0000000..b4469f3 --- /dev/null +++ b/test cases/cmake/3 advanced no dep/meson.build @@ -0,0 +1,17 @@ +project('cmakeSubTest_advanced', ['c', 'cpp']) + +# Test the "normal" subproject call +sub_pro = subproject('cmMod') +sub_dep = sub_pro.get_variable('cmModLib_dep') + +# Test the dependency shortcut +shortcut_dep = dependency('ttabadbneiobevn', fallback: ['cmMod', 'cmModLib_dep']) + +# Build some files +exe1 = executable('main1', ['main.cpp'], dependencies: [sub_dep]) +exe2 = executable('main2', ['main.cpp'], dependencies: [shortcut_dep]) +test('test1', exe1) +test('test2', exe2) + +# Test if we can also extract executables +test('test3', sub_pro.get_variable('testEXE')) diff --git a/test cases/cmake/3 advanced no dep/subprojects/cmMod/CMakeLists.txt b/test cases/cmake/3 advanced no dep/subprojects/cmMod/CMakeLists.txt new file mode 100644 index 0000000..57f0a64 --- /dev/null +++ b/test cases/cmake/3 advanced no dep/subprojects/cmMod/CMakeLists.txt @@ -0,0 +1,19 @@ +cmake_minimum_required(VERSION 3.5) + +project(cmMod) +set(CMAKE_CXX_STANDARD 14) + +include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/lib) + +set(CONFIG_OPT 42) +configure_file("config.h.in" "${CMAKE_CURRENT_BINARY_DIR}/config.h" @ONLY) + +add_library(cmModLib SHARED lib/cmMod.cpp) +include(GenerateExportHeader) +generate_export_header(cmModLib) + +add_executable(testEXE main.cpp) + +target_link_libraries(testEXE cmModLib) + +install(TARGETS cmModLib testEXE LIBRARY DESTINATION lib RUNTIME DESTINATION bin) diff --git a/test cases/cmake/3 advanced no dep/subprojects/cmMod/config.h.in b/test cases/cmake/3 advanced no dep/subprojects/cmMod/config.h.in new file mode 100644 index 0000000..f538ac9 --- /dev/null +++ b/test cases/cmake/3 advanced no dep/subprojects/cmMod/config.h.in @@ -0,0 +1,3 @@ +#pragma once + +#define CONFIG_OPT @CONFIG_OPT@ diff --git a/test cases/cmake/3 advanced no dep/subprojects/cmMod/lib/cmMod.cpp b/test cases/cmake/3 advanced no dep/subprojects/cmMod/lib/cmMod.cpp new file mode 100644 index 0000000..741e8df --- /dev/null +++ b/test cases/cmake/3 advanced no dep/subprojects/cmMod/lib/cmMod.cpp @@ -0,0 +1,16 @@ +#include "cmMod.hpp" +#include "config.h" + +#if CONFIG_OPT != 42 +#error "Invalid value of CONFIG_OPT" +#endif + +using namespace std; + +cmModClass::cmModClass(string foo) { + str = foo + " World"; +} + +string cmModClass::getStr() const { + return str; +} diff --git a/test cases/cmake/3 advanced no dep/subprojects/cmMod/lib/cmMod.hpp b/test cases/cmake/3 advanced no dep/subprojects/cmMod/lib/cmMod.hpp new file mode 100644 index 0000000..52f576b --- /dev/null +++ b/test cases/cmake/3 advanced no dep/subprojects/cmMod/lib/cmMod.hpp @@ -0,0 +1,13 @@ +#pragma once + +#include <string> +#include "cmmodlib_export.h" + +class CMMODLIB_EXPORT cmModClass { + private: + std::string str; + public: + cmModClass(std::string foo); + + std::string getStr() const; +}; diff --git a/test cases/cmake/3 advanced no dep/subprojects/cmMod/main.cpp b/test cases/cmake/3 advanced no dep/subprojects/cmMod/main.cpp new file mode 100644 index 0000000..cd21042 --- /dev/null +++ b/test cases/cmake/3 advanced no dep/subprojects/cmMod/main.cpp @@ -0,0 +1,10 @@ +#include <iostream> +#include "lib/cmMod.hpp" + +using namespace std; + +int main() { + cmModClass obj("Hello (LIB TEST)"); + cout << obj.getStr() << endl; + return 0; +} diff --git a/test cases/cmake/3 code gen/main.cpp b/test cases/cmake/4 code gen/main.cpp index 3ddbf63..3ddbf63 100644 --- a/test cases/cmake/3 code gen/main.cpp +++ b/test cases/cmake/4 code gen/main.cpp diff --git a/test cases/cmake/3 code gen/meson.build b/test cases/cmake/4 code gen/meson.build index daa93ce..a592dfb 100644 --- a/test cases/cmake/3 code gen/meson.build +++ b/test cases/cmake/4 code gen/meson.build @@ -1,4 +1,4 @@ -project('cmake_code_gen', ['cpp']) +project('cmake_code_gen', ['c', 'cpp']) # Subproject with the "code generator" sub_pro = subproject('cmCodeGen') @@ -15,4 +15,4 @@ generated = custom_target( # Build the exe exe1 = executable('main1', ['main.cpp', generated]) -test('test1', exe1)
\ No newline at end of file +test('test1', exe1) diff --git a/test cases/cmake/3 code gen/subprojects/cmCodeGen/CMakeLists.txt b/test cases/cmake/4 code gen/subprojects/cmCodeGen/CMakeLists.txt index 268743c..268743c 100644 --- a/test cases/cmake/3 code gen/subprojects/cmCodeGen/CMakeLists.txt +++ b/test cases/cmake/4 code gen/subprojects/cmCodeGen/CMakeLists.txt diff --git a/test cases/cmake/3 code gen/subprojects/cmCodeGen/main.cpp b/test cases/cmake/4 code gen/subprojects/cmCodeGen/main.cpp index 5b7fed2..5b7fed2 100644 --- a/test cases/cmake/3 code gen/subprojects/cmCodeGen/main.cpp +++ b/test cases/cmake/4 code gen/subprojects/cmCodeGen/main.cpp diff --git a/test cases/cmake/3 code gen/test.hpp b/test cases/cmake/4 code gen/test.hpp index 8e25a0a..8e25a0a 100644 --- a/test cases/cmake/3 code gen/test.hpp +++ b/test cases/cmake/4 code gen/test.hpp diff --git a/test cases/cmake/4 object library/main.cpp b/test cases/cmake/5 object library/main.cpp index f383608..f383608 100644 --- a/test cases/cmake/4 object library/main.cpp +++ b/test cases/cmake/5 object library/main.cpp diff --git a/test cases/cmake/5 object library/meson.build b/test cases/cmake/5 object library/meson.build new file mode 100644 index 0000000..76e16be --- /dev/null +++ b/test cases/cmake/5 object library/meson.build @@ -0,0 +1,23 @@ +project('cmake_object_lib_test', ['c', 'cpp']) + +dep_test = dependency('ZLIB', method: 'cmake', required: false) +if not dep_test.found() + error('MESON_SKIP_TEST: zlib is not installed') +endif + +if build_machine.system() == 'windows' + error('MESON_SKIP_TEST: Windows is not supported because of symbol export problems') +endif + +sub_pro = subproject('cmObjLib') +sub_sha = sub_pro.get_variable('lib_sha_dep') +sub_sta = sub_pro.get_variable('lib_sta_dep') + +# Required for the static library +zlib_dep = dependency('zlib') + +exe_sha = executable('shared', ['main.cpp'], dependencies: [sub_sha]) +exe_sta = executable('static', ['main.cpp'], dependencies: [sub_sta, zlib_dep]) + +test('test1', exe_sha) +test('test1', exe_sta) diff --git a/test cases/cmake/4 object library/subprojects/cmObjLib/CMakeLists.txt b/test cases/cmake/5 object library/subprojects/cmObjLib/CMakeLists.txt index ee9be47..ee9be47 100644 --- a/test cases/cmake/4 object library/subprojects/cmObjLib/CMakeLists.txt +++ b/test cases/cmake/5 object library/subprojects/cmObjLib/CMakeLists.txt diff --git a/test cases/cmake/4 object library/subprojects/cmObjLib/libA.cpp b/test cases/cmake/5 object library/subprojects/cmObjLib/libA.cpp index 3736b2c..3736b2c 100644 --- a/test cases/cmake/4 object library/subprojects/cmObjLib/libA.cpp +++ b/test cases/cmake/5 object library/subprojects/cmObjLib/libA.cpp diff --git a/test cases/cmake/4 object library/subprojects/cmObjLib/libA.hpp b/test cases/cmake/5 object library/subprojects/cmObjLib/libA.hpp index 58c9413..58c9413 100644 --- a/test cases/cmake/4 object library/subprojects/cmObjLib/libA.hpp +++ b/test cases/cmake/5 object library/subprojects/cmObjLib/libA.hpp diff --git a/test cases/cmake/4 object library/subprojects/cmObjLib/libB.cpp b/test cases/cmake/5 object library/subprojects/cmObjLib/libB.cpp index b359c29..b359c29 100644 --- a/test cases/cmake/4 object library/subprojects/cmObjLib/libB.cpp +++ b/test cases/cmake/5 object library/subprojects/cmObjLib/libB.cpp diff --git a/test cases/cmake/4 object library/subprojects/cmObjLib/libB.hpp b/test cases/cmake/5 object library/subprojects/cmObjLib/libB.hpp index 71db6b7..71db6b7 100644 --- a/test cases/cmake/4 object library/subprojects/cmObjLib/libB.hpp +++ b/test cases/cmake/5 object library/subprojects/cmObjLib/libB.hpp diff --git a/test cases/cmake/6 object library no dep/main.cpp b/test cases/cmake/6 object library no dep/main.cpp new file mode 100644 index 0000000..f383608 --- /dev/null +++ b/test cases/cmake/6 object library no dep/main.cpp @@ -0,0 +1,9 @@ +#include <iostream> +#include "libA.hpp" +#include "libB.hpp" + +using namespace std; + +int main() { + cout << getLibStr() << " -- " << getZlibVers() << endl; +} diff --git a/test cases/cmake/4 object library/meson.build b/test cases/cmake/6 object library no dep/meson.build index 05cd7f7..8e1eaf9 100644 --- a/test cases/cmake/4 object library/meson.build +++ b/test cases/cmake/6 object library no dep/meson.build @@ -1,14 +1,15 @@ -project('cmake_object_lib_test', ['cpp']) +project('cmake_object_lib_test', ['c', 'cpp']) + +if build_machine.system() == 'windows' + error('MESON_SKIP_TEST: Windows is not supported because of symbol export problems') +endif sub_pro = subproject('cmObjLib') sub_sha = sub_pro.get_variable('lib_sha_dep') sub_sta = sub_pro.get_variable('lib_sta_dep') -# Required for the static library -zlib_dep = dependency('zlib') - exe_sha = executable('shared', ['main.cpp'], dependencies: [sub_sha]) -exe_sta = executable('static', ['main.cpp'], dependencies: [sub_sta, zlib_dep]) +exe_sta = executable('static', ['main.cpp'], dependencies: [sub_sta]) test('test1', exe_sha) test('test1', exe_sta) diff --git a/test cases/cmake/6 object library no dep/subprojects/cmObjLib/CMakeLists.txt b/test cases/cmake/6 object library no dep/subprojects/cmObjLib/CMakeLists.txt new file mode 100644 index 0000000..08c6a18 --- /dev/null +++ b/test cases/cmake/6 object library no dep/subprojects/cmObjLib/CMakeLists.txt @@ -0,0 +1,5 @@ +cmake_minimum_required(VERSION 3.7) + +add_library(lib_obj OBJECT libA.cpp libB.cpp) +add_library(lib_sha SHARED $<TARGET_OBJECTS:lib_obj>) +add_library(lib_sta STATIC $<TARGET_OBJECTS:lib_obj>) diff --git a/test cases/cmake/6 object library no dep/subprojects/cmObjLib/libA.cpp b/test cases/cmake/6 object library no dep/subprojects/cmObjLib/libA.cpp new file mode 100644 index 0000000..3736b2c --- /dev/null +++ b/test cases/cmake/6 object library no dep/subprojects/cmObjLib/libA.cpp @@ -0,0 +1,5 @@ +#include "libA.hpp" + +std::string getLibStr() { + return "Hello World"; +} diff --git a/test cases/cmake/6 object library no dep/subprojects/cmObjLib/libA.hpp b/test cases/cmake/6 object library no dep/subprojects/cmObjLib/libA.hpp new file mode 100644 index 0000000..58c9413 --- /dev/null +++ b/test cases/cmake/6 object library no dep/subprojects/cmObjLib/libA.hpp @@ -0,0 +1,5 @@ +#pragma once + +#include <string> + +std::string getLibStr(); diff --git a/test cases/cmake/6 object library no dep/subprojects/cmObjLib/libB.cpp b/test cases/cmake/6 object library no dep/subprojects/cmObjLib/libB.cpp new file mode 100644 index 0000000..187d10f --- /dev/null +++ b/test cases/cmake/6 object library no dep/subprojects/cmObjLib/libB.cpp @@ -0,0 +1,5 @@ +#include "libB.hpp" + +std::string getZlibVers() { + return "STUB"; +} diff --git a/test cases/cmake/6 object library no dep/subprojects/cmObjLib/libB.hpp b/test cases/cmake/6 object library no dep/subprojects/cmObjLib/libB.hpp new file mode 100644 index 0000000..71db6b7 --- /dev/null +++ b/test cases/cmake/6 object library no dep/subprojects/cmObjLib/libB.hpp @@ -0,0 +1,5 @@ +#pragma once + +#include <string> + +std::string getZlibVers(); diff --git a/test cases/cmake/5 cmake options/meson.build b/test cases/cmake/7 cmake options/meson.build index 3b58515..55813fb 100644 --- a/test cases/cmake/5 cmake options/meson.build +++ b/test cases/cmake/7 cmake options/meson.build @@ -1,3 +1,3 @@ -project('cmake_set_opt', ['c']) +project('cmake_set_opt', ['c', 'cpp']) subproject('cmOpts', method: 'cmake', cmake_options: '-DSOME_CMAKE_VAR=something') diff --git a/test cases/cmake/5 cmake options/subprojects/cmOpts/CMakeLists.txt b/test cases/cmake/7 cmake options/subprojects/cmOpts/CMakeLists.txt index 62b5990..62b5990 100644 --- a/test cases/cmake/5 cmake options/subprojects/cmOpts/CMakeLists.txt +++ b/test cases/cmake/7 cmake options/subprojects/cmOpts/CMakeLists.txt |