diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 6f93d1d..1cdd3b6 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -3,7 +3,11 @@ # see https://hub.docker.com/_/gcc/ image: meszarosq/phoenix:latest -build: +stages: + - build + - test + +build-clang: stage: build tags: - linux @@ -11,26 +15,63 @@ build: # instead of calling g++ directly you can also use some build toolkit like make # install the necessary build tools when needed before_script: - - apt update && apt -y install cmake ninja-build # libpolyclipping-dev libnlopt-cxx-dev libboost-dev + - apt update && apt -y install cmake ninja-build git subversion clang-7 # libpolyclipping-dev libnlopt-cxx-dev libboost-dev script: - - mkdir -p build && cd build && cmake .. -GNinja -DCMAKE_BUILD_TYPE=Release -DLIBNEST2D_BUILD_EXAMPLES=ON -DLIBNEST2D_BUILD_UNITTESTS=ON && cmake --build . --target all + - mkdir -p build-clang + - cd build-clang + - cmake .. -GNinja -DCMAKE_CXX_COMPILER=clang++-7 -DCMAKE_C_COMPILER=clang-7 -DCMAKE_BUILD_TYPE=Release -DLIBNEST2D_BUILD_EXAMPLES=ON -DLIBNEST2D_BUILD_UNITTESTS=ON -DRP_ENABLE_DOWNLOADING=ON + - cmake --build . --target all artifacts: paths: - - build/tests/tests_clipper_nlopt + - build-clang/tests/tests_clipper_nlopt # depending on your build setup it's most likely a good idea to cache outputs to reduce the build time cache: paths: - - "build/dependencies/*" + - "build-clang/dependencies/*" + +build-gcc: + stage: build + tags: + - linux + - gcc + # instead of calling g++ directly you can also use some build toolkit like make + # install the necessary build tools when needed + before_script: + - apt update && apt -y install cmake ninja-build git subversion g++ # libpolyclipping-dev libnlopt-cxx-dev libboost-dev + script: + - mkdir -p build-gcc + - cd build-gcc + - cmake .. -GNinja -DCMAKE_BUILD_TYPE=Release -DLIBNEST2D_BUILD_EXAMPLES=ON -DLIBNEST2D_BUILD_UNITTESTS=ON -DRP_ENABLE_DOWNLOADING=ON + - cmake --build . --target all + artifacts: + paths: + - build-gcc/tests/tests_clipper_nlopt + # depending on your build setup it's most likely a good idea to cache outputs to reduce the build time + cache: + paths: + - "build-gcc/dependencies/*" # run tests using the binary built before -test: +test-clang: + stage: test + tags: + - linux + #before_script: + # - apt update && apt -y install libpolyclipping22 libnlopt-cxx0 libnlopt0 + script: + - cd build-clang/tests && ./tests_clipper_nlopt -r "junit" --out report-clang.xml + artifacts: + reports: + junit: build-clang/tests/report-clang.xml + +test-gcc: stage: test tags: - linux #before_script: # - apt update && apt -y install libpolyclipping22 libnlopt-cxx0 libnlopt0 script: - - cd build/tests && ./tests_clipper_nlopt -r "junit" --out report.xml + - cd build-gcc/tests && ./tests_clipper_nlopt -r "junit" --out report-gcc.xml artifacts: reports: - junit: build/tests/report.xml + junit: build-gcc/tests/report-gcc.xml \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 1e390b8..677b54d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -108,34 +108,34 @@ endif() include(CMakePackageConfigHelpers) write_basic_package_version_file( - "${CMAKE_CURRENT_BINARY_DIR}/cmakeexports/Libnest2DConfigVersion.cmake" + "${CMAKE_CURRENT_BINARY_DIR}/cmakeexports/${PROJECT_NAME}ConfigVersion.cmake" VERSION 1.0 COMPATIBILITY AnyNewerVersion ) install(TARGETS libnest2d libnest2d_headeronly ${LIBNAME} - EXPORT Libnest2DTargets + EXPORT ${PROJECT_NAME}Targets RUNTIME DESTINATION bin ARCHIVE DESTINATION lib LIBRARY DESTINATION lib INCLUDES DESTINATION include) -export(EXPORT Libnest2DTargets - FILE "${CMAKE_CURRENT_BINARY_DIR}/cmakeexports/Libnest2DTargets.cmake" - NAMESPACE Libnest2D::) +export(EXPORT ${PROJECT_NAME}Targets + FILE "${CMAKE_CURRENT_BINARY_DIR}/cmakeexports/${PROJECT_NAME}Targets.cmake" + NAMESPACE ${PROJECT_NAME}::) configure_file(cmake_modules/Config.cmake.in - "${CMAKE_CURRENT_BINARY_DIR}/cmakeexports/Libnest2DConfig.cmake" + "${CMAKE_CURRENT_BINARY_DIR}/cmakeexports/${PROJECT_NAME}Config.cmake" @ONLY ) -set(ConfigPackageLocation lib/cmake/Libnest2D) +set(ConfigPackageLocation lib/cmake/${PROJECT_NAME}) -install(EXPORT Libnest2DTargets +install(EXPORT ${PROJECT_NAME}Targets FILE - Libnest2DTargets.cmake + ${PROJECT_NAME}Targets.cmake NAMESPACE - Libnest2D:: + ${PROJECT_NAME}:: DESTINATION ${ConfigPackageLocation} ) @@ -154,8 +154,8 @@ endforeach() install( FILES - "${CMAKE_CURRENT_BINARY_DIR}/cmakeexports/Libnest2DConfig.cmake" - "${CMAKE_CURRENT_BINARY_DIR}/cmakeexports/Libnest2DConfigVersion.cmake" + "${CMAKE_CURRENT_BINARY_DIR}/cmakeexports/${PROJECT_NAME}Config.cmake" + "${CMAKE_CURRENT_BINARY_DIR}/cmakeexports/${PROJECT_NAME}ConfigVersion.cmake" "${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules/FindClipper.cmake" "${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules/FindNLopt.cmake" "${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules/FindTBB.cmake" @@ -165,5 +165,7 @@ install( Devel ) -message(STATUS "RP_USED_PACKAGES: ${RP_USED_PACKAGES}") +rp_install_versions_file(${ConfigPackageLocation}) + +message(STATUS "Configuration depends on packages:${_pkgstr}") diff --git a/cmake_modules/Config.cmake.in b/cmake_modules/Config.cmake.in index 96ef9a7..c264d59 100644 --- a/cmake_modules/Config.cmake.in +++ b/cmake_modules/Config.cmake.in @@ -1,4 +1,9 @@ include(CMakeFindDependencyMacro) + +if(EXISTS ${CMAKE_CURRENT_LIST_DIR}/RPPackageVersions.cmake) + include(${CMAKE_CURRENT_LIST_DIR}/RPPackageVersions.cmake) +endif() + set(USED_PACKAGES @RP_USED_PACKAGES@) list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}) @@ -6,6 +11,12 @@ list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}) set(TBB_STATIC @TBB_STATIC@) foreach(package ${USED_PACKAGES}) + if(NOT ${CMAKE_FIND_PACKAGE_NAME}_FIND_QUIETLY) + if(${${package}_VERSION}) + set(_verstr "requested version: ${${package}_VERSION}") + endif() + message(STATUS "Using dependent package: ${package} ${_verstr}") + endif() find_dependency(${package} ${${package}_VERSION}) endforeach() diff --git a/cmake_modules/RequirePackage.cmake b/cmake_modules/RequirePackage.cmake index 7475255..65a8626 100644 --- a/cmake_modules/RequirePackage.cmake +++ b/cmake_modules/RequirePackage.cmake @@ -1,9 +1,13 @@ # RP Package manager default install dir will be set globally set(RP_INSTALL_PREFIX ${CMAKE_BINARY_DIR}/dependencies CACHE STRING "Dependencies location") set(RP_BUILD_TYPE ${CMAKE_BUILD_TYPE} CACHE STRING "Build configuration for the dependencies for single config generators") -option(RP_DISABLE_DOWNLOADING "Disable downloading of packages effectively falling back to find_package functionality" OFF) +option(RP_ENABLE_DOWNLOADING "Enable downloading of bundled packages if not found in system." OFF) set(RP_REPOSITORY_DIR ${PROJECT_SOURCE_DIR}/external CACHE STRING "Package repository location") +set(RP_BUILD_PATH ${CMAKE_BINARY_DIR}/rp_packages_build CACHE STRING "Binary dir for downloaded package builds") + +mark_as_advanced(RP_BUILD_PATH) + # This variable is used to gather dependencies for export (find_dependency will be called for each package) # A list of the requested packages from all require_package calls. set(RP_USED_PACKAGES "" CACHE INTERNAL "") @@ -45,8 +49,6 @@ function(download_package) set(RP_ARGS_VERSION ${ARGV1}) endif() - set(RP_BUILD_PATH ${CMAKE_BINARY_DIR}/rp_packages_build) - file(MAKE_DIRECTORY ${RP_BUILD_PATH}) # Hide output if requested @@ -135,7 +137,7 @@ macro(require_package RP_ARGS_PACKAGE RP_ARGS_VERSION) endif () if(NOT ${RP_ARGS_PACKAGE}_FOUND ) - if (NOT RP_DISABLE_DOWNLOADING) + if (RP_ENABLE_DOWNLOADING) download_package(${RP_ARGS_PACKAGE} ${RP_ARGS_VERSION} ${_QUIET} ${RP_ARGS_UNPARSED_ARGUMENTS} ) @@ -148,6 +150,17 @@ macro(require_package RP_ARGS_PACKAGE RP_ARGS_VERSION) if (NOT RP_ARGS_NO_EXPORT) list(APPEND RP_USED_PACKAGES ${RP_ARGS_PACKAGE}) set(RP_USED_PACKAGES "${RP_USED_PACKAGES}" CACHE INTERNAL "") + set(RP_${RP_ARGS_PACKAGE}_VERSION ${RP_ARGS_VERSION} CACHE INTERNAL "") endif() -endmacro() \ No newline at end of file +endmacro() + +function(rp_install_versions_file dest) + set(_out "") + set(_fname ${RP_BUILD_PATH}/RPPackageVersions.cmake) + foreach(p ${RP_USED_PACKAGES}) + set(_out "${_out}set(${p}_VERSION ${RP_${p}_VERSION})\n") + endforeach() + file(WRITE ${_fname} ${_out}) + install(FILES ${_fname} DESTINATION ${dest}) +endfunction() diff --git a/external/CMakeLists.txt b/external/CMakeLists.txt index 76cbb2c..8a0fd05 100644 --- a/external/CMakeLists.txt +++ b/external/CMakeLists.txt @@ -20,8 +20,6 @@ if (NOT RP_PACKAGES) subdirlist(RP_PACKAGES ${CMAKE_CURRENT_LIST_DIR}) endif() -get_directory_property(hasParent PARENT_DIRECTORY) - if (NOT RP_PACKAGE) add_custom_target(rp ALL) foreach(PACKAGE IN ITEMS ${RP_PACKAGES})