From 7b6e527f440cd7e6f8be2b07cee320ee6ca18786 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Mon, 29 Apr 2024 06:41:38 +0200 Subject: Adding upstream version 1.0.1. Signed-off-by: Daniel Baumann --- .../2 advanced/subprojects/cmMod/CMakeLists.txt | 38 ++++++++++++++++++++++ .../cmake/2 advanced/subprojects/cmMod/config.h.in | 3 ++ .../2 advanced/subprojects/cmMod/lib/cmMod.cpp | 26 +++++++++++++++ .../2 advanced/subprojects/cmMod/lib/cmMod.hpp | 13 ++++++++ .../cmake/2 advanced/subprojects/cmMod/main.cpp | 11 +++++++ 5 files changed, 91 insertions(+) create mode 100644 test cases/cmake/2 advanced/subprojects/cmMod/CMakeLists.txt create mode 100644 test cases/cmake/2 advanced/subprojects/cmMod/config.h.in create mode 100644 test cases/cmake/2 advanced/subprojects/cmMod/lib/cmMod.cpp create mode 100644 test cases/cmake/2 advanced/subprojects/cmMod/lib/cmMod.hpp create mode 100644 test cases/cmake/2 advanced/subprojects/cmMod/main.cpp (limited to 'test cases/cmake/2 advanced/subprojects') 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 +#include "config.h" + +#if CONFIG_OPT != 42 +#error "Invalid value of CONFIG_OPT" +#endif + +#ifdef USE_FRAMEWORK +#include +#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 +#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 +#include +#include "lib/cmMod.hpp" + +using namespace std; + +int main(void) { + cmModClass obj("Hello (LIB TEST)"); + cout << obj.getStr() << " ZLIB: " << zlibVersion() << endl; + return 0; +} -- cgit v1.2.3