From 69b5959c204fe29aaea4f78f0b372c8e48ccf175 Mon Sep 17 00:00:00 2001 From: Mark Meredith Date: Tue, 26 May 2020 13:47:00 -0400 Subject: [PATCH 1/8] WIP --- CMakeLists.txt | 16 ++-------- pmm.cmake | 82 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 84 insertions(+), 14 deletions(-) create mode 100644 pmm.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 191713c..148234c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,20 +15,8 @@ if(CCACHE_FOUND) set( CMAKE_CXX_COMPILER_LAUNCHER ccache ) endif() -# Download automatically, you can also just copy the conan.cmake file -if(NOT EXISTS "${CMAKE_BINARY_DIR}/conan.cmake") - message(STATUS "Downloading conan.cmake from https://github.com/conan-io/cmake-conan") - file(DOWNLOAD "https://raw.githubusercontent.com/conan-io/cmake-conan/master/conan.cmake" - "${CMAKE_BINARY_DIR}/conan.cmake") -endif() - -include(${CMAKE_BINARY_DIR}/conan.cmake) - -conan_cmake_run(REQUIRES - catch2/2.12.1 - cgal/5.0.2 - pegtl/2.8.1@taocpp/stable - BASIC_SETUP CMAKE_TARGETS) +include(pmm.cmake) +pmm(CONAN) include(CTest) include(Catch) diff --git a/pmm.cmake b/pmm.cmake new file mode 100644 index 0000000..c81f85f --- /dev/null +++ b/pmm.cmake @@ -0,0 +1,82 @@ +## MIT License +## +## Copyright (c) 2019 vector-of-bool +## +## Permission is hereby granted, free of charge, to any person obtaining a copy +## of this software and associated documentation files (the "Software"), to deal +## in the Software without restriction, including without limitation the rights +## to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +## copies of the Software, and to permit persons to whom the Software is +## furnished to do so, subject to the following conditions: +## +## The above copyright notice and this permission notice shall be included in all +## copies or substantial portions of the Software. +## +## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +## IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +## FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +## AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +## LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +## OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +## SOFTWARE. + +# Bump this version to change what PMM version is downloaded +set(PMM_VERSION_INIT 1.4.2) + +# Helpful macro to set a variable if it isn't already set +macro(_pmm_set_if_undef varname) + if(NOT DEFINED "${varname}") + set("${varname}" "${ARGN}") + endif() +endmacro() + +## Variables used by this script +# The version: +_pmm_set_if_undef(PMM_VERSION ${PMM_VERSION_INIT}) +# The base URL we download PMM from: +_pmm_set_if_undef(PMM_URL_BASE "https://vector-of-bool.github.io/pmm") +# The real URL we download from (Based on the version) +_pmm_set_if_undef(PMM_URL "${PMM_URL_BASE}/${PMM_VERSION}") +# The directory where we store our downloaded files +_pmm_set_if_undef(PMM_DIR_BASE "${CMAKE_BINARY_DIR}/_pmm") +_pmm_set_if_undef(PMM_DIR "${PMM_DIR_BASE}/${PMM_VERSION}") + +# The file that we first download +set(_PMM_ENTRY_FILE "${PMM_DIR}/entry.cmake") + +# Guard against multiple processes trying to use the PMM dir simultaneously +file(LOCK "${PMM_DIR}/_init-pmm" + GUARD PROCESS + TIMEOUT 10 + RESULT_VARIABLE _lock_res + ) +if(NOT _lock_res STREQUAL "0") + message(WARNING "PMM entry didn't lock the directory ${PMM_DIR} successfully (${_lock_res}). We'll continue as best we can.") + set(_pmm_init_did_lock FALSE) +else() + set(_pmm_init_did_lock TRUE) +endif() + +if(NOT EXISTS "${_PMM_ENTRY_FILE}" OR PMM_ALWAYS_DOWNLOAD) + file( + DOWNLOAD "${PMM_URL}/entry.cmake" + "${_PMM_ENTRY_FILE}.tmp" + STATUS pair + ) + list(GET pair 0 rc) + list(GET pair 1 msg) + if(rc) + message(FATAL_ERROR "Failed to download PMM entry file") + endif() + file(RENAME "${_PMM_ENTRY_FILE}.tmp" "${_PMM_ENTRY_FILE}") +endif() + +# ^^^ DO NOT CHANGE THIS LINE vvv +set(_PMM_BOOTSTRAP_VERSION 2) +# ^^^ DO NOT CHANGE THIS LINE ^^^ + +include("${_PMM_ENTRY_FILE}") + +if(_pmm_init_did_lock) + file(LOCK "${PMM_DIR}/_init-pmm" RELEASE) +endif() -- GitLab From ca0ff9e7ad6aade78a926f09124cb6af44be7c10 Mon Sep 17 00:00:00 2001 From: Mark Meredith Date: Tue, 26 May 2020 14:10:40 -0400 Subject: [PATCH 2/8] Simplify --- CMakeLists.txt | 9 ++++++--- src/csg/CMakeLists.txt | 1 + src/csg/tests/CMakeLists.txt | 7 ++++--- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 148234c..c528bc2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,14 +20,17 @@ pmm(CONAN) include(CTest) include(Catch) -set(MFIXPARSER_CATCH2_DIR ${CONAN_LIB_DIRS_CATCH2}/cmake/Catch2 PARENT_SCOPE) -set(MFIXPARSER_CATCH2_INC ${CONAN_INCLUDE_DIRS_CATCH2} PARENT_SCOPE) + +if(NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) + set(MFIXPARSER_CATCH2_DIR ${CONAN_LIB_DIRS_CATCH2}/cmake/Catch2 PARENT_SCOPE) + set(MFIXPARSER_CATCH2_INC ${CONAN_INCLUDE_DIRS_CATCH2} PARENT_SCOPE) +endif() add_subdirectory(src/csg) target_include_directories(csg PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src ${CONAN_INCLUDE_DIRS_PEGTL} + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src ) target_compile_features(csg PRIVATE cxx_std_17) diff --git a/src/csg/CMakeLists.txt b/src/csg/CMakeLists.txt index 52452cc..0efaa7b 100644 --- a/src/csg/CMakeLists.txt +++ b/src/csg/CMakeLists.txt @@ -12,6 +12,7 @@ add_library(csg target_link_libraries(csg PRIVATE stdc++fs CONAN_PKG::cgal + CONAN_PKG::pegtl ) add_subdirectory(tests) diff --git a/src/csg/tests/CMakeLists.txt b/src/csg/tests/CMakeLists.txt index 7ba26c7..356ac14 100644 --- a/src/csg/tests/CMakeLists.txt +++ b/src/csg/tests/CMakeLists.txt @@ -17,12 +17,13 @@ add_executable(unit_tests_csg EXCLUDE_FROM_ALL ) target_include_directories(unit_tests_csg - PUBLIC ${CMAKE_SOURCE_DIR}/include PRIVATE ${CMAKE_SOURCE_DIR}/src - ${CONAN_INCLUDE_DIRS_CATCH2} ) -target_link_libraries(unit_tests_csg csg) +target_link_libraries(unit_tests_csg + csg + CONAN_PKG::catch2 + ) add_test(NAME run_csg_unittests COMMAND ${CMAKE_COMMAND} -E env ${CMAKE_BINARY_DIR}/bin/unit_tests_csg -- GitLab From 4b1cbad1726e931cbc6d22627eb99d4ebec8e2e1 Mon Sep 17 00:00:00 2001 From: Mark Meredith Date: Tue, 26 May 2020 14:16:02 -0400 Subject: [PATCH 3/8] Test PMM --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 5c1aec5..d7145ba 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -16,7 +16,7 @@ test:meson: test:cmake: script: - - python -m pip install cmake ninja conan + - python -m pip install cmake ninja - cmake -S. -Bbuild -GNinja -DCMAKE_BUILD_TYPE=Debug - cmake --build build --target unit_tests_csg - cd build -- GitLab From b822e960dd1b1fce8c15679968c2bee3a59a9f38 Mon Sep 17 00:00:00 2001 From: Mark Meredith Date: Tue, 26 May 2020 15:14:55 -0400 Subject: [PATCH 4/8] Run tests --- src/csg/tests/CMakeLists.txt | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/csg/tests/CMakeLists.txt b/src/csg/tests/CMakeLists.txt index 356ac14..f3fcb55 100644 --- a/src/csg/tests/CMakeLists.txt +++ b/src/csg/tests/CMakeLists.txt @@ -25,6 +25,4 @@ target_link_libraries(unit_tests_csg CONAN_PKG::catch2 ) -add_test(NAME run_csg_unittests - COMMAND ${CMAKE_COMMAND} -E env ${CMAKE_BINARY_DIR}/bin/unit_tests_csg - ) +catch_discover_tests(unit_tests_csg) -- GitLab From a43957cb9de9b18e4881ff0b144879abcd75b5fa Mon Sep 17 00:00:00 2001 From: Mark Meredith Date: Tue, 26 May 2020 15:20:11 -0400 Subject: [PATCH 5/8] Less verbose --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d7145ba..e771fdc 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -20,6 +20,6 @@ test:cmake: - cmake -S. -Bbuild -GNinja -DCMAKE_BUILD_TYPE=Debug - cmake --build build --target unit_tests_csg - cd build - - ctest --verbose + - ctest tags: - mfix-exa -- GitLab From f8c636504db265b37001cc0aa3add529b551b663 Mon Sep 17 00:00:00 2001 From: Mark Meredith Date: Tue, 26 May 2020 15:20:32 -0400 Subject: [PATCH 6/8] Latest Python 3.7 --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index e771fdc..2fa0fe5 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,4 +1,4 @@ -image: python:3.7.5-buster +image: python:3.7.7-buster variables: GIT_STRATEGY: fetch -- GitLab From c50242ce80a020e864e17a4c924d3226abbbc76c Mon Sep 17 00:00:00 2001 From: Mark Meredith Date: Tue, 26 May 2020 15:24:34 -0400 Subject: [PATCH 7/8] No more submodules --- .gitmodules | 6 ------ subprojects/Catch2 | 1 - subprojects/PEGTL | 1 - 3 files changed, 8 deletions(-) delete mode 160000 subprojects/Catch2 delete mode 160000 subprojects/PEGTL diff --git a/.gitmodules b/.gitmodules index 3fe94d7..e69de29 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +0,0 @@ -[submodule "PEGTL"] - path = subprojects/PEGTL - url = https://github.com/taocpp/PEGTL -[submodule "subprojects/Catch2"] - path = subprojects/Catch2 - url = https://github.com/catchorg/Catch2 diff --git a/subprojects/Catch2 b/subprojects/Catch2 deleted file mode 160000 index 6260962..0000000 --- a/subprojects/Catch2 +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 62609621088df6723e48ea1d164108303511755b diff --git a/subprojects/PEGTL b/subprojects/PEGTL deleted file mode 160000 index 47e878a..0000000 --- a/subprojects/PEGTL +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 47e878ad4fd72c91253c9d47b6f17e001ca2dfcf -- GitLab From 94eef4e97c191fef01fdb3caf3fe0e51b6859394 Mon Sep 17 00:00:00 2001 From: Mark Meredith Date: Tue, 26 May 2020 19:10:34 -0400 Subject: [PATCH 8/8] Setup Conan --- CMakeLists.txt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c528bc2..d111b71 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,11 +18,14 @@ endif() include(pmm.cmake) pmm(CONAN) +conan_basic_setup() +include(${CMAKE_CURRENT_BINARY_DIR}/conanbuildinfo.cmake) + include(CTest) include(Catch) if(NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) - set(MFIXPARSER_CATCH2_DIR ${CONAN_LIB_DIRS_CATCH2}/cmake/Catch2 PARENT_SCOPE) + set(MFIXPARSER_CATCH2_DIR ${CONAN_BUILD_DIRS_CATCH2} PARENT_SCOPE) set(MFIXPARSER_CATCH2_INC ${CONAN_INCLUDE_DIRS_CATCH2} PARENT_SCOPE) endif() -- GitLab