From f73b36c2f342ff9bef5ebc9ca49fa14f54b81d85 Mon Sep 17 00:00:00 2001 From: Daniel Mensinger Date: Sat, 23 Feb 2019 12:23:44 +0100 Subject: [PATCH] cmake: Added test for configure_file --- test cases/cmake/2 advanced/main.cpp | 5 +++++ test cases/cmake/2 advanced/subprojects/cmMod/CMakeLists.txt | 3 +++ test cases/cmake/2 advanced/subprojects/cmMod/config.h.in | 3 +++ test cases/cmake/2 advanced/subprojects/cmMod/lib/cmMod.cpp | 5 +++++ 4 files changed, 16 insertions(+) create mode 100644 test cases/cmake/2 advanced/subprojects/cmMod/config.h.in diff --git a/test cases/cmake/2 advanced/main.cpp b/test cases/cmake/2 advanced/main.cpp index 315c0f7dc..6cc4c0ce3 100644 --- a/test cases/cmake/2 advanced/main.cpp +++ b/test cases/cmake/2 advanced/main.cpp @@ -1,5 +1,10 @@ #include #include +#include "config.h" + +#if CONFIG_OPT != 42 +#error "Invalid value of CONFIG_OPT" +#endif using namespace std; diff --git a/test cases/cmake/2 advanced/subprojects/cmMod/CMakeLists.txt b/test cases/cmake/2 advanced/subprojects/cmMod/CMakeLists.txt index b4cf6982e..3f33e4dcc 100644 --- a/test cases/cmake/2 advanced/subprojects/cmMod/CMakeLists.txt +++ b/test cases/cmake/2 advanced/subprojects/cmMod/CMakeLists.txt @@ -7,6 +7,9 @@ find_package(ZLIB REQUIRED) 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) add_executable(testEXE main.cpp) 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 000000000..f538ac985 --- /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 index cb20844c3..027296e9c 100644 --- a/test cases/cmake/2 advanced/subprojects/cmMod/lib/cmMod.cpp +++ b/test cases/cmake/2 advanced/subprojects/cmMod/lib/cmMod.cpp @@ -1,5 +1,10 @@ #include "cmMod.hpp" #include +#include "config.h" + +#if CONFIG_OPT != 42 +#error "Invalid value of CONFIG_OPT" +#endif using namespace std;