parent
4279255401
commit
7c4f46b65c
34 changed files with 177 additions and 12 deletions
@ -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; |
||||
} |
@ -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…
Reference in new issue