aboutsummaryrefslogtreecommitdiff
path: root/test cases/cmake
diff options
context:
space:
mode:
Diffstat (limited to 'test cases/cmake')
-rw-r--r--test cases/cmake/16 threads/main.cpp9
-rw-r--r--test cases/cmake/16 threads/meson.build8
-rw-r--r--test cases/cmake/16 threads/subprojects/cmMod/CMakeLists.txt9
-rw-r--r--test cases/cmake/16 threads/subprojects/cmMod/cmMod.cpp15
-rw-r--r--test cases/cmake/16 threads/subprojects/cmMod/cmMod.hpp10
-rw-r--r--test cases/cmake/16 threads/subprojects/cmMod/main.cpp9
-rw-r--r--test cases/cmake/2 advanced/meson.build5
-rw-r--r--test cases/cmake/2 advanced/subprojects/cmMod/CMakeLists.txt8
-rw-r--r--test cases/cmake/3 advanced no dep/meson.build5
-rw-r--r--test cases/cmake/3 advanced no dep/subprojects/cmMod/CMakeLists.txt5
10 files changed, 78 insertions, 5 deletions
diff --git a/test cases/cmake/16 threads/main.cpp b/test cases/cmake/16 threads/main.cpp
new file mode 100644
index 0000000..67ee110
--- /dev/null
+++ b/test cases/cmake/16 threads/main.cpp
@@ -0,0 +1,9 @@
+#include "cmMod.hpp"
+
+#include <cstdlib>
+
+int main() {
+ CmMod cc;
+ cc.asyncIncrement();
+ return cc.getNum() == 1 ? EXIT_SUCCESS : EXIT_FAILURE;
+}
diff --git a/test cases/cmake/16 threads/meson.build b/test cases/cmake/16 threads/meson.build
new file mode 100644
index 0000000..d7ade1c
--- /dev/null
+++ b/test cases/cmake/16 threads/meson.build
@@ -0,0 +1,8 @@
+project('cmMod', ['c', 'cpp'])
+
+cm = import('cmake')
+cmMod = cm.subproject('cmMod')
+cmModDep = cmMod.dependency('cmModLib')
+
+exe1 = executable('exe1', ['main.cpp'], dependencies: [cmModDep])
+test('exe1_OK', exe1)
diff --git a/test cases/cmake/16 threads/subprojects/cmMod/CMakeLists.txt b/test cases/cmake/16 threads/subprojects/cmMod/CMakeLists.txt
new file mode 100644
index 0000000..37d32c1
--- /dev/null
+++ b/test cases/cmake/16 threads/subprojects/cmMod/CMakeLists.txt
@@ -0,0 +1,9 @@
+cmake_minimum_required(VERSION 3.5)
+
+project(cmMod CXX)
+set (CMAKE_CXX_STANDARD 14)
+
+find_package(Threads)
+
+add_library(cmModLib STATIC cmMod.cpp)
+target_link_libraries(cmModLib PRIVATE Threads::Threads)
diff --git a/test cases/cmake/16 threads/subprojects/cmMod/cmMod.cpp b/test cases/cmake/16 threads/subprojects/cmMod/cmMod.cpp
new file mode 100644
index 0000000..f971eeb
--- /dev/null
+++ b/test cases/cmake/16 threads/subprojects/cmMod/cmMod.cpp
@@ -0,0 +1,15 @@
+#include "cmMod.hpp"
+
+#include <chrono>
+#include <thread>
+
+using namespace std::chrono_literals;
+
+void CmMod::asyncIncrement() {
+ std::thread t1([this]() {
+ std::this_thread::sleep_for(100ms);
+ num += 1;
+ });
+
+ t1.join();
+}
diff --git a/test cases/cmake/16 threads/subprojects/cmMod/cmMod.hpp b/test cases/cmake/16 threads/subprojects/cmMod/cmMod.hpp
new file mode 100644
index 0000000..1c85a8b
--- /dev/null
+++ b/test cases/cmake/16 threads/subprojects/cmMod/cmMod.hpp
@@ -0,0 +1,10 @@
+#pragma once
+
+class CmMod {
+private:
+ int num = 0;
+
+public:
+ inline int getNum() const { return num; }
+ void asyncIncrement();
+};
diff --git a/test cases/cmake/16 threads/subprojects/cmMod/main.cpp b/test cases/cmake/16 threads/subprojects/cmMod/main.cpp
new file mode 100644
index 0000000..67ee110
--- /dev/null
+++ b/test cases/cmake/16 threads/subprojects/cmMod/main.cpp
@@ -0,0 +1,9 @@
+#include "cmMod.hpp"
+
+#include <cstdlib>
+
+int main() {
+ CmMod cc;
+ cc.asyncIncrement();
+ return cc.getNum() == 1 ? EXIT_SUCCESS : EXIT_FAILURE;
+}
diff --git a/test cases/cmake/2 advanced/meson.build b/test cases/cmake/2 advanced/meson.build
index 385a49b..a10db1c 100644
--- a/test cases/cmake/2 advanced/meson.build
+++ b/test cases/cmake/2 advanced/meson.build
@@ -10,11 +10,14 @@ cm = import('cmake')
# Test the "normal" subproject call
sub_pro = cm.subproject('cmMod')
sub_dep = sub_pro.dependency('cmModLib')
+sub_sta = sub_pro.dependency('cmModLibStatic')
# Build some files
exe1 = executable('main1', ['main.cpp'], dependencies: [sub_dep])
+exe2 = executable('main2', ['main.cpp'], dependencies: [sub_sta])
test('test1', exe1)
+test('test2', exe2)
# Test if we can also extract executables
assert(sub_pro.target_type('testEXE') == 'executable', 'The type must be executable for obvious reasons')
-test('test2', sub_pro.target('testEXE'))
+test('test3', sub_pro.target('testEXE'))
diff --git a/test cases/cmake/2 advanced/subprojects/cmMod/CMakeLists.txt b/test cases/cmake/2 advanced/subprojects/cmMod/CMakeLists.txt
index 05ccb9e..50b1049 100644
--- a/test cases/cmake/2 advanced/subprojects/cmMod/CMakeLists.txt
+++ b/test cases/cmake/2 advanced/subprojects/cmMod/CMakeLists.txt
@@ -10,7 +10,8 @@ include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR} ${CM
set(CONFIG_OPT 42)
configure_file("config.h.in" "${CMAKE_CURRENT_BINARY_DIR}/config.h" @ONLY)
-add_library(cmModLib SHARED lib/cmMod.cpp)
+add_library(cmModLib SHARED lib/cmMod.cpp)
+add_library(cmModLibStatic STATIC lib/cmMod.cpp)
include(GenerateExportHeader)
generate_export_header(cmModLib)
@@ -18,7 +19,10 @@ set_target_properties(cmModLib PROPERTIES VERSION 1.0.1)
add_executable(testEXE main.cpp)
-target_link_libraries(cmModLib ZLIB::ZLIB)
+target_link_libraries(cmModLib ZLIB::ZLIB)
+target_link_libraries(cmModLibStatic ZLIB::ZLIB)
target_link_libraries(testEXE cmModLib)
+target_compile_definitions(cmModLibStatic PUBLIC CMMODLIB_STATIC_DEFINE)
+
install(TARGETS cmModLib testEXE LIBRARY DESTINATION lib RUNTIME DESTINATION bin)
diff --git a/test cases/cmake/3 advanced no dep/meson.build b/test cases/cmake/3 advanced no dep/meson.build
index c10dbf5..0d1e127 100644
--- a/test cases/cmake/3 advanced no dep/meson.build
+++ b/test cases/cmake/3 advanced no dep/meson.build
@@ -5,11 +5,14 @@ cm = import('cmake')
# Test the "normal" subproject call
sub_pro = cm.subproject('cmMod')
sub_dep = sub_pro.dependency('cmModLib')
+sub_sta = sub_pro.dependency('cmModLibStatic')
# Build some files
exe1 = executable('main1', ['main.cpp'], dependencies: [sub_dep])
+exe2 = executable('main2', ['main.cpp'], dependencies: [sub_sta])
test('test1', exe1)
+test('test2', exe2)
# Test if we can also extract executables
assert(sub_pro.target_type('testEXE') == 'executable', 'The type must be executable for obvious reasons')
-test('test2', sub_pro.target('testEXE'))
+test('test3', sub_pro.target('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
index 2f6267d..38c1fff 100644
--- a/test cases/cmake/3 advanced no dep/subprojects/cmMod/CMakeLists.txt
+++ b/test cases/cmake/3 advanced no dep/subprojects/cmMod/CMakeLists.txt
@@ -8,7 +8,8 @@ include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR} ${CM
set(CONFIG_OPT 42)
configure_file("config.h.in" "${CMAKE_CURRENT_BINARY_DIR}/config.h" @ONLY)
-add_library(cmModLib SHARED lib/cmMod.cpp)
+add_library(cmModLib SHARED lib/cmMod.cpp)
+add_library(cmModLibStatic STATIC lib/cmMod.cpp)
include(GenerateExportHeader)
generate_export_header(cmModLib)
@@ -18,4 +19,6 @@ add_executable(testEXE main.cpp)
target_link_libraries(testEXE cmModLib)
+target_compile_definitions(cmModLibStatic PUBLIC CMMODLIB_STATIC_DEFINE)
+
install(TARGETS cmModLib testEXE LIBRARY DESTINATION lib RUNTIME DESTINATION bin)