From 564506a885df1f03fdac67b157df034422023657 Mon Sep 17 00:00:00 2001 From: Chuck Atkins Date: Wed, 26 Sep 2018 10:46:34 -0400 Subject: [PATCH] cmake: add import config tests --- test/CMakeLists.txt | 7 +++++++ test/cmake_add_subdirectory/CMakeLists.txt | 15 +++++++++++++++ .../cmake_add_subdirectory/project/CMakeLists.txt | 13 +++++++++++++ test/cmake_add_subdirectory/project/main.cpp | 8 ++++++++ test/cmake_import/CMakeLists.txt | 15 +++++++++++++++ test/cmake_import/project/CMakeLists.txt | 12 ++++++++++++ test/cmake_import/project/main.cpp | 8 ++++++++ test/cmake_import_minver/CMakeLists.txt | 15 +++++++++++++++ test/cmake_import_minver/project/CMakeLists.txt | 8 ++++++++ test/cmake_import_minver/project/main.cpp | 8 ++++++++ 10 files changed, 109 insertions(+) create mode 100644 test/cmake_add_subdirectory/CMakeLists.txt create mode 100644 test/cmake_add_subdirectory/project/CMakeLists.txt create mode 100644 test/cmake_add_subdirectory/project/main.cpp create mode 100644 test/cmake_import/CMakeLists.txt create mode 100644 test/cmake_import/project/CMakeLists.txt create mode 100644 test/cmake_import/project/main.cpp create mode 100644 test/cmake_import_minver/CMakeLists.txt create mode 100644 test/cmake_import_minver/project/CMakeLists.txt create mode 100644 test/cmake_import_minver/project/main.cpp diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index c0f40728f..14493bd4c 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -133,3 +133,10 @@ foreach(file ${files}) endif() endforeach() + +############################################################################# +# Test the generated build configs +############################################################################# +add_subdirectory(cmake_import) +add_subdirectory(cmake_import_minver) +add_subdirectory(cmake_add_subdirectory) diff --git a/test/cmake_add_subdirectory/CMakeLists.txt b/test/cmake_add_subdirectory/CMakeLists.txt new file mode 100644 index 000000000..ad04547e7 --- /dev/null +++ b/test/cmake_add_subdirectory/CMakeLists.txt @@ -0,0 +1,15 @@ +add_test(NAME cmake_add_subdirectory_configure + COMMAND ${CMAKE_COMMAND} + -G "${CMAKE_GENERATOR}" + -Dnlohmann_json_source=${PROJECT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/project +) +add_test(NAME cmake_add_subdirectory_build + COMMAND ${CMAKE_COMMAND} --build . +) +set_tests_properties(cmake_add_subdirectory_configure PROPERTIES + FIXTURES_SETUP cmake_add_subdirectory +) +set_tests_properties(cmake_add_subdirectory_build PROPERTIES + FIXTURES_REQUIRED cmake_add_subdirectory +) diff --git a/test/cmake_add_subdirectory/project/CMakeLists.txt b/test/cmake_add_subdirectory/project/CMakeLists.txt new file mode 100644 index 000000000..2c5be183b --- /dev/null +++ b/test/cmake_add_subdirectory/project/CMakeLists.txt @@ -0,0 +1,13 @@ +cmake_minimum_required(VERSION 3.8) + +project(DummyImport CXX) + +set(JSON_BuildTests OFF CACHE INTERNAL "") +add_subdirectory(${nlohmann_json_source} + ${CMAKE_CURRENT_BINARY_DIR}/nlohmann_json) + +add_executable(with_namespace_target main.cpp) +target_link_libraries(with_namespace_target nlohmann_json::nlohmann_json) + +add_executable(without_namespace_target main.cpp) +target_link_libraries(without_namespace_target nlohmann_json) diff --git a/test/cmake_add_subdirectory/project/main.cpp b/test/cmake_add_subdirectory/project/main.cpp new file mode 100644 index 000000000..d2d118b85 --- /dev/null +++ b/test/cmake_add_subdirectory/project/main.cpp @@ -0,0 +1,8 @@ +#include + +int main(int argc, char **argv) +{ + nlohmann::json j; + + return 0; +} diff --git a/test/cmake_import/CMakeLists.txt b/test/cmake_import/CMakeLists.txt new file mode 100644 index 000000000..911c342c6 --- /dev/null +++ b/test/cmake_import/CMakeLists.txt @@ -0,0 +1,15 @@ +add_test(NAME cmake_import_configure + COMMAND ${CMAKE_COMMAND} + -G "${CMAKE_GENERATOR}" + -Dnlohmann_json_DIR=${PROJECT_BINARY_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/project +) +add_test(NAME cmake_import_build + COMMAND ${CMAKE_COMMAND} --build . +) +set_tests_properties(cmake_import_configure PROPERTIES + FIXTURES_SETUP cmake_import +) +set_tests_properties(cmake_import_build PROPERTIES + FIXTURES_REQUIRED cmake_import +) diff --git a/test/cmake_import/project/CMakeLists.txt b/test/cmake_import/project/CMakeLists.txt new file mode 100644 index 000000000..d268d72c1 --- /dev/null +++ b/test/cmake_import/project/CMakeLists.txt @@ -0,0 +1,12 @@ +cmake_minimum_required(VERSION 3.8) + +project(DummyImport CXX) + +find_package(nlohmann_json REQUIRED) + +add_executable(with_namespace_target main.cpp) +target_link_libraries(with_namespace_target nlohmann_json::nlohmann_json) + +add_executable(without_namespace_target main.cpp) +target_link_libraries(without_namespace_target nlohmann_json) + diff --git a/test/cmake_import/project/main.cpp b/test/cmake_import/project/main.cpp new file mode 100644 index 000000000..d2d118b85 --- /dev/null +++ b/test/cmake_import/project/main.cpp @@ -0,0 +1,8 @@ +#include + +int main(int argc, char **argv) +{ + nlohmann::json j; + + return 0; +} diff --git a/test/cmake_import_minver/CMakeLists.txt b/test/cmake_import_minver/CMakeLists.txt new file mode 100644 index 000000000..8cef2fabb --- /dev/null +++ b/test/cmake_import_minver/CMakeLists.txt @@ -0,0 +1,15 @@ +add_test(NAME cmake_import_minver_configure + COMMAND ${CMAKE_COMMAND} + -G "${CMAKE_GENERATOR}" + -Dnlohmann_json_DIR=${PROJECT_BINARY_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/project +) +add_test(NAME cmake_import_minver_build + COMMAND ${CMAKE_COMMAND} --build . +) +set_tests_properties(cmake_import_minver_configure PROPERTIES + FIXTURES_SETUP cmake_import_minver +) +set_tests_properties(cmake_import_minver_build PROPERTIES + FIXTURES_REQUIRED cmake_import_minver +) diff --git a/test/cmake_import_minver/project/CMakeLists.txt b/test/cmake_import_minver/project/CMakeLists.txt new file mode 100644 index 000000000..eeef32960 --- /dev/null +++ b/test/cmake_import_minver/project/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.8) + +project(DummyImportMinVer CXX) + +find_package(nlohmann_json 3.2.0 REQUIRED) + +add_executable(with_namespace_target main.cpp) +target_link_libraries(with_namespace_target nlohmann_json::nlohmann_json) diff --git a/test/cmake_import_minver/project/main.cpp b/test/cmake_import_minver/project/main.cpp new file mode 100644 index 000000000..d2d118b85 --- /dev/null +++ b/test/cmake_import_minver/project/main.cpp @@ -0,0 +1,8 @@ +#include + +int main(int argc, char **argv) +{ + nlohmann::json j; + + return 0; +}