cmake: Fixed test cases for windows

pull/4969/head
Daniel Mensinger 6 years ago
parent 4279255401
commit 7c4f46b65c
No known key found for this signature in database
GPG Key ID: 54DD94C131E277D4
  1. 2
      test cases/cmake/1 basic/meson.build
  2. 4
      test cases/cmake/1 basic/subprojects/cmMod/CMakeLists.txt
  3. 3
      test cases/cmake/1 basic/subprojects/cmMod/cmMod.hpp
  4. 7
      test cases/cmake/2 advanced/meson.build
  5. 3
      test cases/cmake/2 advanced/subprojects/cmMod/CMakeLists.txt
  6. 3
      test cases/cmake/2 advanced/subprojects/cmMod/lib/cmMod.hpp
  7. 15
      test cases/cmake/3 advanced no dep/main.cpp
  8. 17
      test cases/cmake/3 advanced no dep/meson.build
  9. 19
      test cases/cmake/3 advanced no dep/subprojects/cmMod/CMakeLists.txt
  10. 3
      test cases/cmake/3 advanced no dep/subprojects/cmMod/config.h.in
  11. 16
      test cases/cmake/3 advanced no dep/subprojects/cmMod/lib/cmMod.cpp
  12. 13
      test cases/cmake/3 advanced no dep/subprojects/cmMod/lib/cmMod.hpp
  13. 10
      test cases/cmake/3 advanced no dep/subprojects/cmMod/main.cpp
  14. 0
      test cases/cmake/4 code gen/main.cpp
  15. 2
      test cases/cmake/4 code gen/meson.build
  16. 0
      test cases/cmake/4 code gen/subprojects/cmCodeGen/CMakeLists.txt
  17. 0
      test cases/cmake/4 code gen/subprojects/cmCodeGen/main.cpp
  18. 0
      test cases/cmake/4 code gen/test.hpp
  19. 0
      test cases/cmake/5 object library/main.cpp
  20. 23
      test cases/cmake/5 object library/meson.build
  21. 0
      test cases/cmake/5 object library/subprojects/cmObjLib/CMakeLists.txt
  22. 0
      test cases/cmake/5 object library/subprojects/cmObjLib/libA.cpp
  23. 0
      test cases/cmake/5 object library/subprojects/cmObjLib/libA.hpp
  24. 0
      test cases/cmake/5 object library/subprojects/cmObjLib/libB.cpp
  25. 0
      test cases/cmake/5 object library/subprojects/cmObjLib/libB.hpp
  26. 9
      test cases/cmake/6 object library no dep/main.cpp
  27. 11
      test cases/cmake/6 object library no dep/meson.build
  28. 5
      test cases/cmake/6 object library no dep/subprojects/cmObjLib/CMakeLists.txt
  29. 5
      test cases/cmake/6 object library no dep/subprojects/cmObjLib/libA.cpp
  30. 5
      test cases/cmake/6 object library no dep/subprojects/cmObjLib/libA.hpp
  31. 5
      test cases/cmake/6 object library no dep/subprojects/cmObjLib/libB.cpp
  32. 5
      test cases/cmake/6 object library no dep/subprojects/cmObjLib/libB.hpp
  33. 2
      test cases/cmake/7 cmake options/meson.build
  34. 0
      test cases/cmake/7 cmake options/subprojects/cmOpts/CMakeLists.txt

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

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

@ -1,8 +1,9 @@
#pragma once
#include <string>
#include "cmmodlib_export.h"
class cmModClass {
class CMMODLIB_EXPORT cmModClass {
private:
std::string str;
public:

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

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

@ -1,8 +1,9 @@
#pragma once
#include <string>
#include "cmmodlib_export.h"
class cmModClass {
class CMMODLIB_EXPORT cmModClass {
private:
std::string str;
public:

@ -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;
}

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

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

@ -0,0 +1,3 @@
#pragma once
#define CONFIG_OPT @CONFIG_OPT@

@ -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;
}

@ -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;
};

@ -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;
}

@ -1,4 +1,4 @@
project('cmake_code_gen', ['cpp'])
project('cmake_code_gen', ['c', 'cpp'])
# Subproject with the "code generator"
sub_pro = subproject('cmCodeGen')

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

@ -0,0 +1,9 @@
#include <iostream>
#include "libA.hpp"
#include "libB.hpp"
using namespace std;
int main() {
cout << getLibStr() << " -- " << getZlibVers() << endl;
}

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

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

@ -0,0 +1,5 @@
#include "libA.hpp"
std::string getLibStr() {
return "Hello World";
}

@ -0,0 +1,5 @@
#pragma once
#include <string>
std::string getLibStr();

@ -0,0 +1,5 @@
#include "libB.hpp"
std::string getZlibVers() {
return "STUB";
}

@ -0,0 +1,5 @@
#pragma once
#include <string>
std::string getZlibVers();

@ -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')
Loading…
Cancel
Save