summaryrefslogtreecommitdiffstats
path: root/test cases/cmake/2 advanced/subprojects
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-29 04:41:38 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-29 04:41:38 +0000
commit7b6e527f440cd7e6f8be2b07cee320ee6ca18786 (patch)
tree4a2738d69fa2814659fdadddf5826282e73d81f4 /test cases/cmake/2 advanced/subprojects
parentInitial commit. (diff)
downloadmeson-7b6e527f440cd7e6f8be2b07cee320ee6ca18786.tar.xz
meson-7b6e527f440cd7e6f8be2b07cee320ee6ca18786.zip
Adding upstream version 1.0.1.upstream/1.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'test cases/cmake/2 advanced/subprojects')
-rw-r--r--test cases/cmake/2 advanced/subprojects/cmMod/CMakeLists.txt38
-rw-r--r--test cases/cmake/2 advanced/subprojects/cmMod/config.h.in3
-rw-r--r--test cases/cmake/2 advanced/subprojects/cmMod/lib/cmMod.cpp26
-rw-r--r--test cases/cmake/2 advanced/subprojects/cmMod/lib/cmMod.hpp13
-rw-r--r--test cases/cmake/2 advanced/subprojects/cmMod/main.cpp11
5 files changed, 91 insertions, 0 deletions
diff --git a/test cases/cmake/2 advanced/subprojects/cmMod/CMakeLists.txt b/test cases/cmake/2 advanced/subprojects/cmMod/CMakeLists.txt
new file mode 100644
index 0000000..0750117
--- /dev/null
+++ b/test cases/cmake/2 advanced/subprojects/cmMod/CMakeLists.txt
@@ -0,0 +1,38 @@
+cmake_minimum_required(VERSION 3.5)
+
+project(cmMod)
+set(CMAKE_CXX_STANDARD 14)
+
+find_package(ZLIB REQUIRED)
+
+include_directories(${CMAKE_CURRENT_BINARY_DIR} ${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)
+add_library(cmModLibStatic STATIC lib/cmMod.cpp)
+include(GenerateExportHeader)
+generate_export_header(cmModLib)
+
+set_target_properties(cmModLib PROPERTIES VERSION 1.0.1)
+
+add_executable(testEXE main.cpp "${CMAKE_CURRENT_BINARY_DIR}/config.h")
+
+target_link_libraries(cmModLib ZLIB::ZLIB)
+target_link_libraries(cmModLibStatic ;ZLIB::ZLIB;)
+target_link_libraries(testEXE cmModLib)
+
+if(APPLE)
+ find_library(COREFOUNDATION_FRAMEWORK "CoreFoundation")
+ if(NOT COREFOUNDATION_FRAMEWORK)
+ message(FATAL_ERROR "CoreFoundation framework not found")
+ endif()
+
+ target_link_libraries(cmModLibStatic "${COREFOUNDATION_FRAMEWORK}")
+ target_compile_definitions(cmModLibStatic PUBLIC USE_FRAMEWORK)
+endif()
+
+target_compile_definitions(cmModLibStatic PUBLIC CMMODLIB_STATIC_DEFINE)
+
+install(TARGETS testEXE LIBRARY DESTINATION lib RUNTIME DESTINATION bin)
diff --git a/test cases/cmake/2 advanced/subprojects/cmMod/config.h.in b/test cases/cmake/2 advanced/subprojects/cmMod/config.h.in
new file mode 100644
index 0000000..f538ac9
--- /dev/null
+++ b/test cases/cmake/2 advanced/subprojects/cmMod/config.h.in
@@ -0,0 +1,3 @@
+#pragma once
+
+#define CONFIG_OPT @CONFIG_OPT@
diff --git a/test cases/cmake/2 advanced/subprojects/cmMod/lib/cmMod.cpp b/test cases/cmake/2 advanced/subprojects/cmMod/lib/cmMod.cpp
new file mode 100644
index 0000000..eb41438
--- /dev/null
+++ b/test cases/cmake/2 advanced/subprojects/cmMod/lib/cmMod.cpp
@@ -0,0 +1,26 @@
+#include "cmMod.hpp"
+#include <zlib.h>
+#include "config.h"
+
+#if CONFIG_OPT != 42
+#error "Invalid value of CONFIG_OPT"
+#endif
+
+#ifdef USE_FRAMEWORK
+#include <CoreFoundation/CoreFoundation.h>
+#endif
+
+using namespace std;
+
+cmModClass::cmModClass(string foo) {
+ str = foo + " World " + zlibVersion();
+
+#ifdef USE_FRAMEWORK
+ CFStringRef ref = CFStringCreateWithCString(NULL, str.c_str(), kCFStringEncodingUTF8);
+ CFRelease(ref);
+#endif
+}
+
+string cmModClass::getStr() const {
+ return str;
+}
diff --git a/test cases/cmake/2 advanced/subprojects/cmMod/lib/cmMod.hpp b/test cases/cmake/2 advanced/subprojects/cmMod/lib/cmMod.hpp
new file mode 100644
index 0000000..52f576b
--- /dev/null
+++ b/test cases/cmake/2 advanced/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/2 advanced/subprojects/cmMod/main.cpp b/test cases/cmake/2 advanced/subprojects/cmMod/main.cpp
new file mode 100644
index 0000000..77fab68
--- /dev/null
+++ b/test cases/cmake/2 advanced/subprojects/cmMod/main.cpp
@@ -0,0 +1,11 @@
+#include <iostream>
+#include <zlib.h>
+#include "lib/cmMod.hpp"
+
+using namespace std;
+
+int main(void) {
+ cmModClass obj("Hello (LIB TEST)");
+ cout << obj.getStr() << " ZLIB: " << zlibVersion() << endl;
+ return 0;
+}