From 21b1432fb5454d5d4e0743747a40ec2da95a7901 Mon Sep 17 00:00:00 2001 From: Koen Schmeets Date: Tue, 29 Aug 2023 11:48:20 +0200 Subject: [PATCH 01/19] Make shared boost the default, simpler VERSION_STRING, fix Doxygen --- install.sh | 4 ++ src/CMakeLists.txt | 43 +++------------- src/Doxyfile | 11 ++-- src/cxxlib/cxxlib.cmake | 4 ++ src/emscriptenlib/emscriptenlib.cmake | 4 ++ src/nodejslib/nodejslib.cmake | 5 ++ src/ocl.cpp | 1 - src/ocl.hpp | 4 ++ src/pythonlib/ocl.cpp | 2 - src/pythonlib/pythonlib.cmake | 4 ++ src/version_string.cmake | 73 --------------------------- 11 files changed, 37 insertions(+), 118 deletions(-) delete mode 100644 src/version_string.cmake diff --git a/install.sh b/install.sh index 3d7f51b0..8d373032 100755 --- a/install.sh +++ b/install.sh @@ -427,6 +427,7 @@ build_cxxlib() { ${OCL_GENERATOR_PLATFORM:+"-A ${OCL_GENERATOR_PLATFORM}"} \ -D CMAKE_BUILD_TYPE="${build_type}" \ -D BUILD_CXX_LIB="ON" \ + -D USE_STATIC_BOOST="ON" \ -D Boost_ADDITIONAL_VERSIONS="${boost_additional_versions}" \ ${OCL_DISABLE_OPENMP:+"-DUSE_OPENMP=OFF"} \ ${OCL_INSTALL_PREFIX:+"-DCMAKE_INSTALL_PREFIX=${OCL_INSTALL_PREFIX}"} \ @@ -478,6 +479,7 @@ build_nodejslib() { ${OCL_GENERATOR:+"--generator=${OCL_GENERATOR}"} \ ${OCL_GENERATOR_PLATFORM:+"--platform=${OCL_GENERATOR_PLATFORM}"} \ --CDBUILD_NODEJS_LIB="ON" \ + --CDUSE_STATIC_BOOST="ON" \ --CDBoost_ADDITIONAL_VERSIONS="${boost_additional_versions}" \ --CDCMAKE_INSTALL_PREFIX="${OCL_INSTALL_PREFIX:-"${install_prefix_fallback}"}" \ ${OCL_DISABLE_OPENMP:+"--CDUSE_OPENMP=OFF"} \ @@ -538,6 +540,7 @@ ${OCL_BOOST_PREFIX:+"-D BOOST_ROOT=${OCL_BOOST_PREFIX} "}" ${OCL_GENERATOR_PLATFORM:+"-A ${OCL_GENERATOR_PLATFORM}"} \ -D CMAKE_BUILD_TYPE="${build_type}" \ -D BUILD_PY_LIB="ON" \ + -D USE_STATIC_BOOST="ON" \ -D Boost_ADDITIONAL_VERSIONS="${boost_additional_versions}" \ -D CMAKE_INSTALL_PREFIX="${OCL_INSTALL_PREFIX:-"${install_prefix_fallback}"}" \ ${OCL_DISABLE_OPENMP:+"-DUSE_OPENMP=OFF"} \ @@ -569,6 +572,7 @@ build_emscriptenlib() { -D CMAKE_BUILD_TYPE="${build_type}" \ -D BUILD_EMSCRIPTEN_LIB="ON" \ -D USE_OPENMP="OFF" \ + -D USE_STATIC_BOOST="ON" \ -D Boost_ADDITIONAL_VERSIONS="${boost_additional_versions}" \ -D CMAKE_INSTALL_PREFIX="${OCL_INSTALL_PREFIX:-"${install_prefix_fallback}"}" \ ${OCL_BOOST_PREFIX:+"-DBOOST_ROOT=${OCL_BOOST_PREFIX}"} \ diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 4915cea5..9c6a445a 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -50,6 +50,9 @@ option(VERSION_STRING option(USE_PY_3 "Use Python V3" ON) +option(USE_STATIC_BOOST + "Use static boost" OFF) + if(NOT BUILD_CXX_LIB) message(STATUS " Note: will NOT build pure c++ library") endif() @@ -99,7 +102,9 @@ endif() include_directories(${CMAKE_CURRENT_BINARY_DIR}) set(Boost_DEBUG ON CACHE BOOL "boost-debug") -set(Boost_USE_STATIC_LIBS ON CACHE BOOL "boost-use-static-libs") +if(USE_STATIC_BOOST) + set(Boost_USE_STATIC_LIBS ON CACHE BOOL "boost-use-static-libs") +endif() if(DEFINED ENV{BOOST_ROOT} OR DEFINED BOOST_ROOT) set(Boost_NO_SYSTEM_PATHS ON) endif() @@ -160,40 +165,6 @@ if(USE_OPENMP) endif() endif() -if(EXISTS ${PROJECT_SOURCE_DIR}/version_string.hpp) - file(STRINGS "${PROJECT_SOURCE_DIR}/version_string.hpp" PROJECT_BUILD_SPECIFICATION REGEX "^[ \t]*#define[ \t]+VERSION_STRING[ \t]+.*$") - if(PROJECT_BUILD_SPECIFICATION) - string(REGEX REPLACE ".*#define[ \t]+VERSION_STRING[ \t]+\"(.*)\".*" "\\1" MY_VERSION ${PROJECT_BUILD_SPECIFICATION}) - else() - message(FATAL_ERROR "Data were not found for the required build specification.") - endif() - set(version_string ${PROJECT_SOURCE_DIR}/version_string.hpp) -else() - ################ create version_string.hpp, http://stackoverflow.com/questions/3780667 - # include the output directory, where the version_string.hpp file is generated - include_directories(${CMAKE_CURRENT_BINARY_DIR}) - if(VERSION_STRING) - set( vstring "//version_string.hpp - written by cmake. changes will be lost!\n" - "#ifndef VERSION_STRING\n" - "#define VERSION_STRING \"${VERSION_STRING}\"\n" - "#endif\n" - ) - file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/version_string.hpp ${vstring} ) - set(MY_VERSION ${VERSION_STRING}) - set(version_string ${VERSION_STRING}) - else() - include(version_string.cmake) - # now parse the git commit id: - string(REGEX REPLACE "([0-9]+).*" "\\1" GIT_MAJOR_VERSION "${GIT_COMMIT_ID}" ) - string(REGEX REPLACE "[0-9]+.([0-9]+)-.*" "\\1" GIT_MINOR_VERSION "${GIT_COMMIT_ID}" ) - string(REGEX REPLACE "[0-9]+.[0-9]+-(.*)-.*" "\\1" GIT_PATCH_VERSION "${GIT_COMMIT_ID}" ) - set(MY_VERSION "${GIT_MAJOR_VERSION}.${GIT_MINOR_VERSION}.${GIT_PATCH_VERSION}" CACHE STRING "name") - set(version_string ${CMAKE_CURRENT_BINARY_DIR}/version_string.hpp) - endif() -endif() - -message(STATUS "OpenCAMLib version: ${MY_VERSION}") - # this defines the source-files set(OCL_SRC ${PROJECT_SOURCE_DIR}/ocl.cpp @@ -336,7 +307,7 @@ if(BUILD_DOC) message(STATUS "dvips command DVIPS_CONVERTER not found but usually required.") endif() - configure_file(${PROJECT_SOURCE_DIR}/Doxyfile ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile COPYONLY) + configure_file(${PROJECT_SOURCE_DIR}/Doxyfile ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile @ONLY) set(DOXY_CONFIG ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile) execute_process( diff --git a/src/Doxyfile b/src/Doxyfile index 79133582..9cc80ec1 100644 --- a/src/Doxyfile +++ b/src/Doxyfile @@ -898,12 +898,11 @@ WARN_LOGFILE = # spaces. See also FILE_PATTERNS and EXTENSION_MAPPING # Note: If this tag is empty the current directory is searched. -INPUT = "../src/manual.hpp" \ - "../src/cutters" \ - "../src/algo" \ - "../src/geo" \ - "../src/dropcutter" \ - "../src/common" +INPUT = "@CMAKE_CURRENT_SOURCE_DIR@/cutters" \ + "@CMAKE_CURRENT_SOURCE_DIR@/algo" \ + "@CMAKE_CURRENT_SOURCE_DIR@/geo" \ + "@CMAKE_CURRENT_SOURCE_DIR@/dropcutter" \ + "@CMAKE_CURRENT_SOURCE_DIR@/common" # This tag can be used to specify the character encoding of the source files # that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses diff --git a/src/cxxlib/cxxlib.cmake b/src/cxxlib/cxxlib.cmake index 7c97e5d3..c3dd4aa3 100644 --- a/src/cxxlib/cxxlib.cmake +++ b/src/cxxlib/cxxlib.cmake @@ -8,6 +8,10 @@ add_library(ocl ${OCL_COMMON_SRC} ) +if(DEFINED VERSION_STRING) + target_compile_definitions(ocl VERSION_STRING=${VERSION_STRING}) +endif() + if(WIN32) # on windows, prefix the library with lib, and make sure the .lib file is installed as well set_target_properties(ocl PROPERTIES diff --git a/src/emscriptenlib/emscriptenlib.cmake b/src/emscriptenlib/emscriptenlib.cmake index d857a877..fb5ff4f5 100644 --- a/src/emscriptenlib/emscriptenlib.cmake +++ b/src/emscriptenlib/emscriptenlib.cmake @@ -25,6 +25,10 @@ add_executable(ocl ${PROJECT_SOURCE_DIR}/emscriptenlib/emscriptenlib.cpp ) +if(DEFINED VERSION_STRING) + target_compile_definitions(ocl VERSION_STRING=${VERSION_STRING}) +endif() + target_link_libraries( ocl ${Boost_LIBRARIES} diff --git a/src/nodejslib/nodejslib.cmake b/src/nodejslib/nodejslib.cmake index a39be700..8fead368 100644 --- a/src/nodejslib/nodejslib.cmake +++ b/src/nodejslib/nodejslib.cmake @@ -45,6 +45,11 @@ target_link_libraries( Boost::boost ${CMAKE_JS_LIB} ) + +if(DEFINED VERSION_STRING) + target_compile_definitions(ocl VERSION_STRING=${VERSION_STRING}) +endif() + if(USE_OPENMP) target_link_libraries(ocl PRIVATE OpenMP::OpenMP_CXX) endif() diff --git a/src/ocl.cpp b/src/ocl.cpp index 31e4f8e5..580aa956 100644 --- a/src/ocl.cpp +++ b/src/ocl.cpp @@ -23,7 +23,6 @@ #ifdef _OPENMP #include #endif -#include "version_string.hpp" namespace ocl { diff --git a/src/ocl.hpp b/src/ocl.hpp index 5cd6149b..583db842 100644 --- a/src/ocl.hpp +++ b/src/ocl.hpp @@ -23,6 +23,10 @@ #include +#ifndef VERSION_STRING +#define VERSION_STRING "unknown-version" +#endif + namespace ocl { int max_threads(); diff --git a/src/pythonlib/ocl.cpp b/src/pythonlib/ocl.cpp index 72f0efc8..b652a190 100644 --- a/src/pythonlib/ocl.cpp +++ b/src/pythonlib/ocl.cpp @@ -27,8 +27,6 @@ #include #include -#include "version_string.hpp" // autogenerated by version_string.cmake - std::string ocl_docstring() { return "OpenCAMLib docstring"; } diff --git a/src/pythonlib/pythonlib.cmake b/src/pythonlib/pythonlib.cmake index 87b47e89..a352a84a 100644 --- a/src/pythonlib/pythonlib.cmake +++ b/src/pythonlib/pythonlib.cmake @@ -25,6 +25,10 @@ MODULE pythonlib/ocl.cpp ) +if(DEFINED VERSION_STRING) + target_compile_definitions(ocl VERSION_STRING=${VERSION_STRING}) +endif() + target_link_libraries( ocl PRIVATE diff --git a/src/version_string.cmake b/src/version_string.cmake deleted file mode 100644 index 88ffc645..00000000 --- a/src/version_string.cmake +++ /dev/null @@ -1,73 +0,0 @@ -#use git for a pretty commit id -#uses 'git describe --tags', so tags are required in the repo -#create a tag with 'git tag ' and 'git push --tags' - -#version_string.hpp will define VERSION_STRING to something like "test-1-g5e1fb47" -# where test is the name of the last tagged git revision, 1 is the number of commits since that tag, -# 'g' is ???, and 5e1fb47 is the first 7 chars of the git sha1 commit id. - - -find_package(Git) - -if(NOT GIT_FOUND) - # cmake 2.8.1 (in Lucid) does not have a git Cmake interface - # cmake 2.8.5 (in Oneiric) does have it - message(STATUS "couldn't find Cmake interface to git, old version of Cmake? looking by hand...") - execute_process( - COMMAND git --version - RESULT_VARIABLE RC - ) - if (${RC} EQUAL 0) - set(GIT_FOUND 1) - set(GIT_EXECUTABLE "git") - else() - message(ERROR "couldn't run git executable!") - endif() -endif() - -if(GIT_FOUND) - execute_process( - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} - COMMAND ${GIT_EXECUTABLE} describe --tags - RESULT_VARIABLE res_var - OUTPUT_VARIABLE GIT_COM_ID - OUTPUT_STRIP_TRAILING_WHITESPACE - ERROR_QUIET - ) - if( NOT ${res_var} EQUAL 0 ) - message( WARNING "Git failed (not a repo, or no tags)." ) - file(READ "git-tag.txt" GIT_COM_ID) - string( REPLACE "\n" "" GIT_COMMIT_ID ${GIT_COM_ID} ) - message( STATUS "version_string.cmake read from file GIT_COMMIT_ID: " ${GIT_COMMIT_ID}) - else() - string( REPLACE "\n" "" GIT_COMMIT_ID ${GIT_COM_ID} ) - message( STATUS "version_string.cmake git set GIT_COMMIT_ID: " ${GIT_COMMIT_ID}) - endif() - -else() - # if we don't have git, try to read git-tag from file instead - file(READ "git-tag.txt" GIT_COMMIT_ID) - - #set( GIT_COMMIT_ID "unknown (git not found!)") - message( STATUS "version_string.cmake read from file git-tag.txt: " ${GIT_COMMIT_ID}) - #message( WARNING "Git not found. Reading tag from git-tag.txt instead: " ${GIT_COMMIT_ID}) -endif() - -set( vstring "//version_string.hpp - written by cmake. changes will be lost!\n" - "#ifndef VERSION_STRING\n" - "#define VERSION_STRING \"${GIT_COMMIT_ID}\"\n" - "#endif\n" -) - -file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/version_string.hpp ${vstring} ) -set_source_files_properties( - ${CMAKE_CURRENT_BINARY_DIR}/version_string.hpp - PROPERTIES GENERATED TRUE - HEADER_FILE_ONLY TRUE -) - -# copy the file to the final header only if the version changes -# reduces needless rebuilds -#execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different -# version_string.hpp.txt /version_string.hpp) - From 74f93c6b62208b02e6c6571fe7ba9a665564cb0f Mon Sep 17 00:00:00 2001 From: Koen Schmeets Date: Tue, 29 Aug 2023 11:51:42 +0200 Subject: [PATCH 02/19] Use Doxygen::doxygen in stead of the deprecated DOXYGEN_EXECUTABLE --- src/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 9c6a445a..16d94fe3 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -318,7 +318,7 @@ if(BUILD_DOC) OUTPUT doc/latex/index.tex doc/html/index.html - COMMAND ${DOXYGEN_EXECUTABLE} ${DOXY_CONFIG} + COMMAND Doxygen::doxygen ${DOXY_CONFIG} COMMENT building LaTex & HTML docs ) From 5b711d2c476f986e27678a8f60f9b3801a952235 Mon Sep 17 00:00:00 2001 From: Koen Schmeets Date: Tue, 29 Aug 2023 11:54:08 +0200 Subject: [PATCH 03/19] Add missing scope to target_compile_definitions --- src/cxxlib/cxxlib.cmake | 2 +- src/emscriptenlib/emscriptenlib.cmake | 2 +- src/nodejslib/nodejslib.cmake | 2 +- src/pythonlib/pythonlib.cmake | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/cxxlib/cxxlib.cmake b/src/cxxlib/cxxlib.cmake index c3dd4aa3..b3e81be7 100644 --- a/src/cxxlib/cxxlib.cmake +++ b/src/cxxlib/cxxlib.cmake @@ -9,7 +9,7 @@ add_library(ocl ) if(DEFINED VERSION_STRING) - target_compile_definitions(ocl VERSION_STRING=${VERSION_STRING}) + target_compile_definitions(ocl PUBLIC VERSION_STRING=${VERSION_STRING}) endif() if(WIN32) diff --git a/src/emscriptenlib/emscriptenlib.cmake b/src/emscriptenlib/emscriptenlib.cmake index fb5ff4f5..a4a33e33 100644 --- a/src/emscriptenlib/emscriptenlib.cmake +++ b/src/emscriptenlib/emscriptenlib.cmake @@ -26,7 +26,7 @@ add_executable(ocl ) if(DEFINED VERSION_STRING) - target_compile_definitions(ocl VERSION_STRING=${VERSION_STRING}) + target_compile_definitions(ocl PUBLIC VERSION_STRING=${VERSION_STRING}) endif() target_link_libraries( diff --git a/src/nodejslib/nodejslib.cmake b/src/nodejslib/nodejslib.cmake index 8fead368..537a16ba 100644 --- a/src/nodejslib/nodejslib.cmake +++ b/src/nodejslib/nodejslib.cmake @@ -47,7 +47,7 @@ target_link_libraries( ) if(DEFINED VERSION_STRING) - target_compile_definitions(ocl VERSION_STRING=${VERSION_STRING}) + target_compile_definitions(ocl PUBLIC VERSION_STRING=${VERSION_STRING}) endif() if(USE_OPENMP) diff --git a/src/pythonlib/pythonlib.cmake b/src/pythonlib/pythonlib.cmake index a352a84a..9b9be5d3 100644 --- a/src/pythonlib/pythonlib.cmake +++ b/src/pythonlib/pythonlib.cmake @@ -26,7 +26,7 @@ MODULE ) if(DEFINED VERSION_STRING) - target_compile_definitions(ocl VERSION_STRING=${VERSION_STRING}) + target_compile_definitions(ocl PUBLIC VERSION_STRING=${VERSION_STRING}) endif() target_link_libraries( From 99feb9a005c28fd4b77b0ac82c93ea8ccae2cab2 Mon Sep 17 00:00:00 2001 From: Koen Schmeets Date: Tue, 29 Aug 2023 12:00:06 +0200 Subject: [PATCH 04/19] Fix default VERSION_STRING --- src/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 16d94fe3..5dd7493a 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -45,7 +45,7 @@ option(USE_OPENMP "Use OpenMP for parallel computation" ON) option(VERSION_STRING - "Set version string") + "Set version string" "unknown-version") option(USE_PY_3 "Use Python V3" ON) From 190f002a1c72462556d403c032d5cacc0fde23ec Mon Sep 17 00:00:00 2001 From: Koen Schmeets Date: Tue, 29 Aug 2023 12:11:23 +0200 Subject: [PATCH 05/19] Try to fix version string --- src/CMakeLists.txt | 6 +++++- src/cxxlib/cxxlib.cmake | 4 +--- src/emscriptenlib/emscriptenlib.cmake | 4 +--- src/nodejslib/nodejslib.cmake | 4 +--- src/pythonlib/pythonlib.cmake | 4 +--- 5 files changed, 9 insertions(+), 13 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 5dd7493a..b96b956d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -45,7 +45,7 @@ option(USE_OPENMP "Use OpenMP for parallel computation" ON) option(VERSION_STRING - "Set version string" "unknown-version") + "Set version string" OFF) option(USE_PY_3 "Use Python V3" ON) @@ -73,6 +73,10 @@ if(NOT BUILD_DOC) message(STATUS " Note: will NOT build ocl documentation") endif() +if (NOT VERSION_STRING) + set(VERSION_STRING "unknown-version") +endif() + # figure out the gcc version include(gcc_version.cmake) diff --git a/src/cxxlib/cxxlib.cmake b/src/cxxlib/cxxlib.cmake index b3e81be7..4d59a7a3 100644 --- a/src/cxxlib/cxxlib.cmake +++ b/src/cxxlib/cxxlib.cmake @@ -8,9 +8,7 @@ add_library(ocl ${OCL_COMMON_SRC} ) -if(DEFINED VERSION_STRING) - target_compile_definitions(ocl PUBLIC VERSION_STRING=${VERSION_STRING}) -endif() +target_compile_definitions(ocl PUBLIC VERSION_STRING="${VERSION_STRING}") if(WIN32) # on windows, prefix the library with lib, and make sure the .lib file is installed as well diff --git a/src/emscriptenlib/emscriptenlib.cmake b/src/emscriptenlib/emscriptenlib.cmake index a4a33e33..a19c495d 100644 --- a/src/emscriptenlib/emscriptenlib.cmake +++ b/src/emscriptenlib/emscriptenlib.cmake @@ -25,9 +25,7 @@ add_executable(ocl ${PROJECT_SOURCE_DIR}/emscriptenlib/emscriptenlib.cpp ) -if(DEFINED VERSION_STRING) - target_compile_definitions(ocl PUBLIC VERSION_STRING=${VERSION_STRING}) -endif() +target_compile_definitions(ocl PUBLIC VERSION_STRING="${VERSION_STRING}") target_link_libraries( ocl diff --git a/src/nodejslib/nodejslib.cmake b/src/nodejslib/nodejslib.cmake index 537a16ba..d163baac 100644 --- a/src/nodejslib/nodejslib.cmake +++ b/src/nodejslib/nodejslib.cmake @@ -46,9 +46,7 @@ target_link_libraries( ${CMAKE_JS_LIB} ) -if(DEFINED VERSION_STRING) - target_compile_definitions(ocl PUBLIC VERSION_STRING=${VERSION_STRING}) -endif() +target_compile_definitions(ocl PUBLIC VERSION_STRING="${VERSION_STRING}") if(USE_OPENMP) target_link_libraries(ocl PRIVATE OpenMP::OpenMP_CXX) diff --git a/src/pythonlib/pythonlib.cmake b/src/pythonlib/pythonlib.cmake index 9b9be5d3..61645076 100644 --- a/src/pythonlib/pythonlib.cmake +++ b/src/pythonlib/pythonlib.cmake @@ -25,9 +25,7 @@ MODULE pythonlib/ocl.cpp ) -if(DEFINED VERSION_STRING) - target_compile_definitions(ocl PUBLIC VERSION_STRING=${VERSION_STRING}) -endif() +target_compile_definitions(ocl PUBLIC VERSION_STRING="${VERSION_STRING}") target_link_libraries( ocl From 2bf3b4b08b5697ed10669e93f6b3aabdc4a2471b Mon Sep 17 00:00:00 2001 From: Koen Schmeets Date: Wed, 6 Sep 2023 22:26:03 +0200 Subject: [PATCH 06/19] Simplify install script, fix lto issue on macos --- .github/workflows/cd.yml | 6 +- README.rst | 11 +- VERSION | 1 + install.sh | 294 +++++++++++++++------------------------ pyproject.toml | 3 +- src/cxxlib/cxxlib.cmake | 9 +- 6 files changed, 127 insertions(+), 197 deletions(-) create mode 100644 VERSION diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index f60defb9..551965ae 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -68,7 +68,7 @@ jobs: else version="$(date '+%Y.%-m.%-d').dev${GITHUB_RUN_NUMBER}" fi - echo "${version}" > src/git-tag.txt + echo "${version}" > VERSION if [ "${{ matrix.docker_image }}" != "" ]; then export OCL_DOCKER_IMAGE="${{ matrix.docker_image }}" @@ -156,7 +156,7 @@ jobs: else version="$(date '+%Y.%-m.%-d')-dev.${GITHUB_RUN_NUMBER}" fi - echo "${version}" > src/git-tag.txt + echo "${version}" > VERSION if [ "${{ matrix.docker_image }}" != "" ]; then export OCL_DOCKER_IMAGE="${{ matrix.docker_image }}" @@ -272,7 +272,7 @@ jobs: version="$(date '+%Y.%-m.%-d').dev${GITHUB_RUN_NUMBER}" fi sed -i.bak "s/^version = .*/version = \"${version}\"/g" pyproject.toml && rm pyproject.toml.bak - echo "${version}" > src/git-tag.txt + echo "${version}" > VERSION - name: Set up QEMU uses: docker/setup-qemu-action@v2 if: matrix.architecture == 'aarch64' diff --git a/README.rst b/README.rst index 689f3a9f..0648bd8e 100644 --- a/README.rst +++ b/README.rst @@ -183,6 +183,7 @@ Install - Visual Studio Build Tools (https://visualstudio.microsoft.com/visual-cpp-build-tools/) - Git (https://git-scm.com/download/win) - CMake (https://git-scm.com/download/win) +- Boost (https://www.boost.org/users/download/) By downloading the installers from the internet, or by using your package manager. @@ -228,7 +229,7 @@ Now you can compile OpenCAMLib like this (make sure to replace the ``path/to/`` mkdir build cd build emcmake cmake \ - -D CMAKE_BUILD_TYPE="Release" \ + -D CMAKE_BUILD_TYPE="RelWithDebInfo" \ -D BUILD_EMSCRIPTEN_LIB="ON" \ -D USE_OPENMP="OFF" \ -D CMAKE_INSTALL_PREFIX="/path/to/opencamlib/src/npmpackage/build" \ @@ -262,10 +263,10 @@ Next, use cmake-js to compile the library: --directory ".." \ --out "." \ --parallel 4 \ - --CD BUILD_NODEJS_LIB="ON" \ - --CD USE_OPENMP="ON" \ - --CD CMAKE_INSTALL_PREFIX="/path/to/opencamlib/build/Release/$(node --print 'process.platform')-nodejs-$(node --print 'process.arch')" \ - --CD BOOST_ROOT="/path/to/boost" \ + --CDBUILD_NODEJS_LIB="ON" \ + --CDUSE_OPENMP="ON" \ + --CDCMAKE_INSTALL_PREFIX="/path/to/opencamlib/build/Release/$(node --print 'process.platform')-nodejs-$(node --print 'process.arch')" \ + --CDBOOST_ROOT="/path/to/boost" \ --config "Release" =================== diff --git a/VERSION b/VERSION new file mode 100644 index 00000000..c9df6993 --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +2023.09.6 \ No newline at end of file diff --git a/install.sh b/install.sh index 8d373032..b801d9a2 100755 --- a/install.sh +++ b/install.sh @@ -8,17 +8,17 @@ project_dir=$(pwd) print_help() { cat << EOF -Usage: ./install.sh [OPTIONS] +Usage: ./install.sh [OPTIONS] [LIBRARY] -Options: +LIBRARY: one of: cxx, nodejs, python, emscripten + +OPTIONS: --clean Clean the build folder before compiling a library (only valid with --build-library) - --build-library Compile a library with CMake (one of: cxx, nodejs, python, emscripten) --build-type Choose the build type (one of: debug, release) (only valid with --build-library) --disable-openmp Disable OpenMP in the build. (only valid with --build-library) --install-system-deps Install dependencies for compiling libraries (only aware of apt, brew and choco at the moment) --install-ci-deps Install curl and, when the platform is macos, installs OpenMP for the given architecture (see: --macos-architecture) --install-boost Install Boost from source - --install-boost-from-repo Install Boost (pre-compiled) from platform specific package repositories --install Install the CMake install targets to the prefix (see: --install-prefix) --sudo-install Install the CMake install targets to the prefix with root privileges (see: --install-prefix) @@ -50,7 +50,37 @@ EOF exit 1 } +primary='\033[1;34m' +secondary='\033[1;35m' +nc='\033[0m' +prettyprint() { + printf "${primary}${1}${nc}${secondary}${2}${nc}\n" +} + +get_os() { + if [ "${OCL_PLATFORM}" ]; then + echo "${OCL_PLATFORM}" + else + if [[ "${OSTYPE}" =~ ^darwin.* ]]; then + echo "macos" + elif [[ "${OSTYPE}" =~ ^linux.* ]]; then + echo "linux" + else + echo "windows" + fi + fi +} +determined_os=$(get_os) +prettyprint "Determined OS: " "${determined_os}" + +# defaults +OCL_CLEAN="1" +OCL_BUILD_TYPE="release" +OCL_PLATFORM="${determined_os}" +OCL_INSTALL="1" + original_args="$*" +positional_args=() while [[ "$#" -gt 0 ]]; do case $1 in --clean) OCL_CLEAN="1"; ;; @@ -64,7 +94,6 @@ while [[ "$#" -gt 0 ]]; do --sudo-install) OCL_SUDO_INSTALL="1"; ;; --install-prefix) OCL_INSTALL_PREFIX="$2"; shift ;; --install-boost) OCL_INSTALL_BOOST="1"; ;; - --install-boost-from-repo) OCL_INSTALL_BOOST_FROM_REPO="1"; ;; --boost-prefix) OCL_BOOST_PREFIX="$2"; shift ;; --boost-address-model) OCL_BOOST_ADDRESS_MODEL="$2"; shift ;; --boost-architecture) OCL_BOOST_ARCHITECTURE="$2"; shift ;; @@ -84,24 +113,24 @@ while [[ "$#" -gt 0 ]]; do echo $1 print_help ;; *) + # Append unmatched arguments to the positional_args array + positional_args+=("$1") esac shift done +if [[ ${#positional_args[@]} != 1 ]]; then + print_help + exit 0 +fi + +OCL_BUILD_LIBRARY="${positional_args[0]}" +if [[ "${OCL_BUILD_LIBRARY}" == "cxx" ]]; then + OCL_SUDO_INSTALL="1" +fi + verify_args() { - if [ -n "${OCL_CLEAN}" ] && [ -z "${OCL_BUILD_LIBRARY}" ]; then - echo "Cannot set --clean without building a library. add the --build-library [lib] option or remove the --clean option" - exit 1 - elif [ -n "${OCL_BUILD_TYPE}" ] && [ -z "${OCL_BUILD_LIBRARY}" ]; then - echo "Cannot set --build-type without building a library. add the --build-library [lib] option or remove the --build-type option" - exit 1 - elif [ -n "${OCL_TEST}" ] && [ -z "${OCL_BUILD_LIBRARY}" ]; then - echo "Cannot set --test without building a library. add the --build-library [lib] option or remove the --test option" - exit 1 - elif [ -n "${OCL_DISABLE_OPENMP}" ] && [ -z "${OCL_BUILD_LIBRARY}" ]; then - echo "Cannot set --disable-openmp without building a library. add the --build-library [lib] option or remove the --disable-openmp option" - exit 1 - elif [ -n "${OCL_INSTALL_PREFIX}" ] && [ -z "${OCL_INSTALL}" ] && [ -z "${OCL_SUDO_INSTALL}" ]; then + if [ -n "${OCL_INSTALL_PREFIX}" ] && [ -z "${OCL_INSTALL}" ] && [ -z "${OCL_SUDO_INSTALL}" ]; then echo "WARN: Settings --install-prefix without setting --install or --sudo-install. add --install or --sudo-install option or remove the --install-prefix option" elif [ -n "${OCL_BOOST_WITH_PYTHON}" ] && [ -z "${OCL_INSTALL_BOOST}" ]; then echo "WARN: Setting --boost-with-python without setting --install-boost. add --install-boost or remove the --boost-with-python option" @@ -125,31 +154,9 @@ else build_type_lower="release" fi build_dir="${project_dir}/build/${OCL_BUILD_LIBRARY}/${build_type_lower}" -primary='\033[1;34m' -secondary='\033[1;35m' -nc='\033[0m' -prettyprint() { - printf "${primary}${1}${nc}${secondary}${2}${nc}\n" -} prettyprint "./install.sh " "$original_args" -get_os() { - if [ "${OCL_PLATFORM}" ]; then - echo "${OCL_PLATFORM}" - else - if [[ "${OSTYPE}" =~ ^darwin.* ]]; then - echo "macos" - elif [[ "${OSTYPE}" =~ ^linux.* ]]; then - echo "linux" - else - echo "windows" - fi - fi -} -determined_os=$(get_os) -prettyprint "Determined OS: " "${determined_os}" - num_procs() { if [ "${determined_os}" = "macos" ]; then sysctl -n hw.logicalcpu @@ -170,46 +177,14 @@ fi install_system_dependencies() { if [ "${determined_os}" = "linux" ]; then sudo apt update - sudo apt install -y --no-install-recommends git cmake curl build-essential - if [ -n "${OCL_INSTALL_BOOST_FROM_REPO}" ]; then - sudo apt install -y --no-install-recommends libboost-dev - fi - if [ "${OCL_BUILD_LIBRARY}" = "python" ]; then - if [ -z "${OCL_PYTHON_EXECUTABLE}" ]; then - sudo apt install -y --no-install-recommends python3 - fi - if [ -n "${OCL_INSTALL_BOOST_FROM_REPO}" ]; then - sudo apt install -y --no-install-recommends libboost-python-dev - fi - fi - if [ "${OCL_BUILD_LIBRARY}" = "nodejs" ]; then - sudo apt install -y --no-install-recommends nodejs npm - fi + sudo apt install -y --no-install-recommends git cmake curl build-essential libboost-dev python3 libboost-python-dev nodejs npm elif [ "${determined_os}" = "macos" ]; then - brew install libomp - if [ -n "${OCL_INSTALL_BOOST_FROM_REPO}" ]; then - brew install boost - fi - if [ "${OCL_BUILD_LIBRARY}" = "python" ]; then - if [ -z "${OCL_PYTHON_EXECUTABLE}" ]; then - brew install python@3.11 - fi - if [ -n "${OCL_INSTALL_BOOST_FROM_REPO}" ]; then - brew install boost-python3 - fi - fi - if [ "${OCL_BUILD_LIBRARY}" = "nodejs" ]; then - brew install node - fi + brew install libomp boost python boost-python3 node else # @todo installing git and cmake fails in github's CI choco install curl --no-progress - if [ -n "${OCL_INSTALL_BOOST_FROM_REPO}" ]; then - choco install boost-msvc-14.3 --no-progress - fi - if [ "${OCL_BUILD_LIBRARY}" = "nodejs" ]; then - choco install nodejs - fi + choco install boost-msvc-14.3 --no-progress + choco install nodejs --no-progress fi } @@ -372,8 +347,7 @@ if [ -n "${OCL_MACOS_ARCHITECTURE}" ]; then fi dependencies_nodejslib () { - cd "${project_dir}/src/nodejslib" - npm install --silent + (cd "${project_dir}/src/nodejslib" && npm install --silent) } dependencies_emscriptenlib () { @@ -387,6 +361,7 @@ dependencies_emscriptenlib () { cd ../emsdk ./emsdk install latest ./emsdk activate latest + cd "${project_dir}" } build_clean() { @@ -395,49 +370,54 @@ build_clean() { cmake_build() { if [ "${determined_os}" = "windows" ]; then - ${OCL_SUDO_INSTALL:+"sudo"} cmake \ + cmake \ --build . \ --config "${build_type}" \ -j "${num_procs}" else - ${OCL_SUDO_INSTALL:+"sudo"} cmake \ + cmake \ --build . \ -j "${num_procs}" fi } cmake_install() { - prettyprint "Installing" - if [ "${determined_os}" = "windows" ]; then - ${OCL_SUDO_INSTALL:+"sudo"} cmake \ - --install . \ - --config "${build_type}" - else - ${OCL_SUDO_INSTALL:+"sudo"} cmake \ - --install . + if [ -n "${OCL_INSTALL}" ] || [ -n "${OCL_SUDO_INSTALL}" ]; then + prettyprint "Installing" + if [ "${determined_os}" = "windows" ]; then + ${OCL_SUDO_INSTALL:+"sudo"} cmake \ + --install . \ + --config "${build_type}" + else + ${OCL_SUDO_INSTALL:+"sudo"} cmake \ + --install . + fi fi } +get_cmake_args() { + echo "-S . \ + -B "${build_dir}" \ + ${OCL_GENERATOR:+"-G ${OCL_GENERATOR}"} \ + ${OCL_GENERATOR_PLATFORM:+"-A ${OCL_GENERATOR_PLATFORM}"} \ + -D CMAKE_BUILD_TYPE="${build_type}" \ + -D USE_STATIC_BOOST="ON" \ + -D Boost_ADDITIONAL_VERSIONS="${boost_additional_versions}" \ + -D VERSION_STRING="2023.09.6" + ${OCL_DISABLE_OPENMP:+"-D USE_OPENMP=OFF"} \ + ${OCL_INSTALL_PREFIX:+"-D CMAKE_INSTALL_PREFIX=${OCL_INSTALL_PREFIX}"} \ + ${OCL_BOOST_PREFIX:+"-D BOOST_ROOT=${OCL_BOOST_PREFIX}"}" +} + +get_cmakejs_args() { + echo "$(get_cmake_args)" | sed -e 's/-D /--CD/g' -e 's/-S/--directory/g' -e 's/-B/--out/g' +} + build_cxxlib() { - mkdir -p "${build_dir}" - cd "${build_dir}" set -x - cmake \ - ${OCL_GENERATOR:+"-G ${OCL_GENERATOR}"} \ - ${OCL_GENERATOR_PLATFORM:+"-A ${OCL_GENERATOR_PLATFORM}"} \ - -D CMAKE_BUILD_TYPE="${build_type}" \ - -D BUILD_CXX_LIB="ON" \ - -D USE_STATIC_BOOST="ON" \ - -D Boost_ADDITIONAL_VERSIONS="${boost_additional_versions}" \ - ${OCL_DISABLE_OPENMP:+"-DUSE_OPENMP=OFF"} \ - ${OCL_INSTALL_PREFIX:+"-DCMAKE_INSTALL_PREFIX=${OCL_INSTALL_PREFIX}"} \ - ${OCL_BOOST_PREFIX:+"-DBOOST_ROOT=${OCL_BOOST_PREFIX}"} \ - ../../.. + cmake $(get_cmake_args) -D BUILD_CXX_LIB="ON" set +x - cmake_build - if [ -n "${OCL_INSTALL}" ] || [ -n "${OCL_SUDO_INSTALL}" ]; then - cmake_install - fi + (cd "${build_dir}" && cmake_build && cmake_install) } test_cxxlib() { @@ -446,16 +426,16 @@ test_cxxlib() { prettyprint "Cleaning build directory..." rm -rf build || true fi - mkdir build || true - cd build set -x cmake \ + -S . \ + -B build \ ${OCL_GENERATOR:+"-G ${OCL_GENERATOR}"} \ ${OCL_GENERATOR_PLATFORM:+"-A ${OCL_GENERATOR_PLATFORM}"} \ -D Boost_ADDITIONAL_VERSIONS="${boost_additional_versions}" \ - ${OCL_BOOST_PREFIX:+"-DBOOST_ROOT=${OCL_BOOST_PREFIX}"} \ - .. + ${OCL_BOOST_PREFIX:+"-DBOOST_ROOT=${OCL_BOOST_PREFIX}"} set +x + cd build cmake_build if [ "${determined_os}" = "windows" ]; then ./test_example.exe @@ -465,30 +445,19 @@ test_cxxlib() { } build_nodejslib() { - mkdir -p "${build_dir}" - cd "${build_dir}" set -x determined_arch=$(node -p 'process.arch') install_prefix_fallback="${project_dir}/src/npmpackage/build/Release/${determined_os}-nodejs-${determined_arch}" - ../../../src/nodejslib/node_modules/.bin/cmake-js \ + src/nodejslib/node_modules/.bin/cmake-js \ build \ - --directory "../../.." \ - --out "." \ + $(get_cmakejs_args) \ --parallel "${num_procs}" \ ${OCL_NODE_ARCH:+"--arch=${OCL_NODE_ARCH}"} \ - ${OCL_GENERATOR:+"--generator=${OCL_GENERATOR}"} \ - ${OCL_GENERATOR_PLATFORM:+"--platform=${OCL_GENERATOR_PLATFORM}"} \ --CDBUILD_NODEJS_LIB="ON" \ - --CDUSE_STATIC_BOOST="ON" \ - --CDBoost_ADDITIONAL_VERSIONS="${boost_additional_versions}" \ --CDCMAKE_INSTALL_PREFIX="${OCL_INSTALL_PREFIX:-"${install_prefix_fallback}"}" \ - ${OCL_DISABLE_OPENMP:+"--CDUSE_OPENMP=OFF"} \ - ${OCL_BOOST_PREFIX:+"--CDBOOST_ROOT=${OCL_BOOST_PREFIX}"} \ --config "${build_type}" set +x - if [ -n "${OCL_INSTALL}" ] || [ -n "${OCL_SUDO_INSTALL}" ]; then - cmake_install - fi + (cd "${build_dir}" && cmake_install) } test_nodejslib() { @@ -514,45 +483,12 @@ get_python_executable() { build_pythonlib() { python_executable=$(get_python_executable) - if [ -n "${OCL_PYTHON_PIP_INSTALL}" ]; then - ${python_executable} -m pip install scikit-build-core distlib pyproject_metadata - # ${python_executable} -m venv env - # if [ "${determined_os}" = "windows" ]; then - # source env/Scripts/activate - # else - # source env/bin/activate - # fi - # forward cmake args - export CMAKE_ARGS="${OCL_GENERATOR:+"-G ${OCL_GENERATOR} "}\ + export CMAKE_ARGS="${OCL_GENERATOR:+"-G ${OCL_GENERATOR} "}\ ${OCL_GENERATOR_PLATFORM:+"-A ${OCL_GENERATOR_PLATFORM} "}\ -D CMAKE_BUILD_TYPE=${build_type} \ --D Boost_ADDITIONAL_VERSIONS=${boost_additional_versions} \ ${OCL_BOOST_PREFIX:+"-D BOOST_ROOT=${OCL_BOOST_PREFIX} "}" - cd "${project_dir}" - ${python_executable} -m pip install --verbose . - else - mkdir -p "${build_dir}" - cd "${build_dir}" - set -x - install_prefix_fallback=$(${python_executable} -c 'import sysconfig; print(sysconfig.get_paths()["purelib"])') - cmake \ - ${OCL_GENERATOR:+"-G ${OCL_GENERATOR}"} \ - ${OCL_GENERATOR_PLATFORM:+"-A ${OCL_GENERATOR_PLATFORM}"} \ - -D CMAKE_BUILD_TYPE="${build_type}" \ - -D BUILD_PY_LIB="ON" \ - -D USE_STATIC_BOOST="ON" \ - -D Boost_ADDITIONAL_VERSIONS="${boost_additional_versions}" \ - -D CMAKE_INSTALL_PREFIX="${OCL_INSTALL_PREFIX:-"${install_prefix_fallback}"}" \ - ${OCL_DISABLE_OPENMP:+"-DUSE_OPENMP=OFF"} \ - ${OCL_PYTHON_PREFIX:+"-DPython3_ROOT_DIR=${OCL_PYTHON_PREFIX}"} \ - ${OCL_BOOST_PREFIX:+"-DBOOST_ROOT=${OCL_BOOST_PREFIX}"} \ - ../../.. - set +x - cmake_build - if [ -n "${OCL_INSTALL}" ] || [ -n "${OCL_SUDO_INSTALL}" ]; then - cmake_install - fi - fi + cd "${project_dir}" + ${python_executable} -m pip install --verbose . } test_pythonlib() { @@ -562,21 +498,15 @@ test_pythonlib() { } build_emscriptenlib() { - mkdir -p "${build_dir}" - cd "${build_dir}" source "${project_dir}/../emsdk/emsdk_env.sh" set -x install_prefix_fallback="${project_dir}/src/npmpackage/build" - emcmake cmake \ - -G "Unix Makefiles" \ - -D CMAKE_BUILD_TYPE="${build_type}" \ + emcmake cmake $(get_cmake_args) \ -D BUILD_EMSCRIPTEN_LIB="ON" \ -D USE_OPENMP="OFF" \ -D USE_STATIC_BOOST="ON" \ - -D Boost_ADDITIONAL_VERSIONS="${boost_additional_versions}" \ - -D CMAKE_INSTALL_PREFIX="${OCL_INSTALL_PREFIX:-"${install_prefix_fallback}"}" \ - ${OCL_BOOST_PREFIX:+"-DBOOST_ROOT=${OCL_BOOST_PREFIX}"} \ - ../../.. + -D CMAKE_INSTALL_PREFIX="${OCL_INSTALL_PREFIX:-"${install_prefix_fallback}"}" + cd "${build_dir}" if [ "${determined_os}" = "windows" ]; then emmake make \ --config "${build_type}" \ @@ -625,7 +555,7 @@ if [ -n "${OCL_CLEAN}" ]; then build_clean fi -if [ "${OCL_BUILD_LIBRARY}" = "cxx" ]; then +if [[ "${OCL_BUILD_LIBRARY}" == "cxx" ]]; then prettyprint "Building C++ library" build_cxxlib if [ -n "${OCL_TEST}" ]; then @@ -634,18 +564,7 @@ if [ "${OCL_BUILD_LIBRARY}" = "cxx" ]; then fi fi -if [ "${OCL_BUILD_LIBRARY}" = "nodejs" ]; then - prettyprint "Installing node.js dependencies" - dependencies_nodejslib - prettyprint "Building node.js library" - build_nodejslib - if [ -n "${OCL_TEST}" ]; then - prettyprint "Testing node.js library" - test_nodejslib - fi -fi - -if [ "${OCL_BUILD_LIBRARY}" = "python" ]; then +if [[ "${OCL_BUILD_LIBRARY}" == "python" ]]; then prettyprint "Building Python library " "${OCL_BOOST_PYTHON_VERSION}" build_pythonlib if [ -n "${OCL_TEST}" ]; then @@ -654,7 +573,7 @@ if [ "${OCL_BUILD_LIBRARY}" = "python" ]; then fi fi -if [ "${OCL_BUILD_LIBRARY}" = "emscripten" ]; then +if [[ "${OCL_BUILD_LIBRARY}" == "emscripten" ]]; then prettyprint "Installing emscripten dependencies" dependencies_emscriptenlib prettyprint "Building emscripten library" @@ -664,3 +583,14 @@ if [ "${OCL_BUILD_LIBRARY}" = "emscripten" ]; then test_emscriptenlib fi fi + +if [[ "${OCL_BUILD_LIBRARY}" == "nodejs" ]]; then + prettyprint "Installing node.js dependencies" + dependencies_nodejslib + prettyprint "Building node.js library" + build_nodejslib + if [ -n "${OCL_TEST}" ]; then + prettyprint "Testing node.js library" + test_nodejslib + fi +fi diff --git a/pyproject.toml b/pyproject.toml index 20be73f3..572c4256 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "opencamlib" -version = "2022.12.18" +version = "2023.09.6" description = "open source computer aided manufacturing algorithms library" readme = "README.rst" authors = [ @@ -44,6 +44,7 @@ wheel.packages = ["src/pythonlib/opencamlib"] BUILD_PY_LIB = "ON" Boost_ADDITIONAL_VERSIONS = "1.80.0;1.79.0;1.78.0;1.77.0;1.76.0;1.75.0;1.74.0;1.73.0;1.72.0;1.71.0;1.70.0" BUILD_DOC = "OFF" +VERSION_STRING="2022.12.18" [tool.cibuildwheel] build = ["cp37*", "cp38*", "cp39*", "cp310*", "cp311*"] diff --git a/src/cxxlib/cxxlib.cmake b/src/cxxlib/cxxlib.cmake index 4d59a7a3..0e1d50fd 100644 --- a/src/cxxlib/cxxlib.cmake +++ b/src/cxxlib/cxxlib.cmake @@ -64,12 +64,9 @@ install( ) if(APPLE) - target_compile_options(ocl PRIVATE -g) - # if(CMAKE_CXX_FLAGS MATCHES "-flto") - set(lto_object ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/ocl-lto.o) - set_property(TARGET ocl APPEND_STRING PROPERTY - LINK_FLAGS " -Wl,-object_path_lto -Wl,${lto_object}") - # endif() + # target_compile_options(ocl PRIVATE -g) # commented out because I think Debug and RelWithDebInfo should already use the -g flag + set_property(TARGET ocl APPEND_STRING PROPERTY + LINK_FLAGS "-Wl,-object_path_lto,ocl-lto.o -Wl,-cache_path_lto,${CMAKE_BINARY_DIR}/LTOCache") add_custom_command(TARGET ocl POST_BUILD COMMAND xcrun dsymutil $ COMMAND xcrun strip -Sl $) From 3365aaf3a19dac9cdd40fd80c13041f805db040f Mon Sep 17 00:00:00 2001 From: Koen Schmeets Date: Wed, 6 Sep 2023 22:28:19 +0200 Subject: [PATCH 07/19] Get rid of --build-library and make it a positional argument --- .github/workflows/cd.yml | 12 ++++++------ .github/workflows/test.yml | 12 ++++++------ install.sh | 8 ++++---- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 551965ae..1a163753 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -81,13 +81,13 @@ jobs: fi ./install.sh \ - --build-library cxx \ --build-type release \ --install-ci-deps \ --install-boost \ --boost-prefix $(pwd) \ --install \ - --install-prefix $(pwd)/dist + --install-prefix $(pwd)/dist \ + cxx - uses: actions/upload-artifact@v3 with: name: ${{ matrix.os_short }}-cxx-${{ matrix.architecture }} @@ -169,14 +169,14 @@ jobs: fi ./install.sh \ - --build-library nodejs \ --build-type release \ --install-ci-deps \ --install-boost \ --boost-prefix $(pwd) \ --node-architecture ${{ matrix.node_architecture }} \ --install \ - --install-prefix $(pwd)/dist + --install-prefix $(pwd)/dist \ + nodejs - uses: actions/upload-artifact@v3 with: name: ${{ matrix.os_short }}-nodejs-${{ matrix.node_architecture }} @@ -330,13 +330,13 @@ jobs: shell: bash run: | ./install.sh \ - --build-library emscripten \ --build-type release \ --install-ci-deps \ --install-boost \ --boost-prefix $(pwd) \ --install \ - --install-prefix $(pwd)/dist + --install-prefix $(pwd)/dist \ + emscripten - uses: actions/upload-artifact@v3 with: name: emscripten diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 93836501..d0bde765 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -40,12 +40,12 @@ jobs: fi ./install.sh \ --install-ci-deps \ - --build-library cxx \ --build-type release \ --install-boost \ --boost-prefix $(pwd) \ --install \ - --test + --test \ + cxx nodejs: name: ${{ matrix.os_short }} node.js runs-on: ${{ matrix.os }} @@ -76,14 +76,14 @@ jobs: fi ./install.sh \ --install-ci-deps \ - --build-library nodejs \ --build-type release \ --node-architecture x64 \ --install-boost \ --boost-prefix $(pwd) \ --install \ --install-prefix $(pwd)/src/npmpackage/build/Release/${{ matrix.libdir }} \ - --test + --test \ + nodejs python: name: ${{ matrix.os_short }} python runs-on: ${{ matrix.os }} @@ -121,11 +121,11 @@ jobs: export OCL_INSTALL_BOOST_FROM_REPO="1" fi ./install.sh \ - --build-library python \ --build-type release \ --install-system-deps \ --python-executable python \ --python-pip-install \ - --test + --test \ + python env: CMAKE_GENERATOR: ${{ matrix.cmake_generator }} diff --git a/install.sh b/install.sh index b801d9a2..2f25aae3 100755 --- a/install.sh +++ b/install.sh @@ -13,9 +13,9 @@ Usage: ./install.sh [OPTIONS] [LIBRARY] LIBRARY: one of: cxx, nodejs, python, emscripten OPTIONS: - --clean Clean the build folder before compiling a library (only valid with --build-library) - --build-type Choose the build type (one of: debug, release) (only valid with --build-library) - --disable-openmp Disable OpenMP in the build. (only valid with --build-library) + --clean Clean the build folder before compiling a library + --build-type Choose the build type (one of: debug, release) + --disable-openmp Disable OpenMP in the build. --install-system-deps Install dependencies for compiling libraries (only aware of apt, brew and choco at the moment) --install-ci-deps Install curl and, when the platform is macos, installs OpenMP for the given architecture (see: --macos-architecture) --install-boost Install Boost from source @@ -43,7 +43,7 @@ OPTIONS: --cmake-generator-platform Set the CMake Generator Platform option, useful for cross compiling on Windows with the Visual Studio generator. --node-architecture Set the node.js architecture to compile for, useful for cross compiling. - --test Run a test script after compiling the library (only valid with --build-library) + --test Run a test script after compiling the library --help Shows this help page EOF From 71a5303b7911b5ab18292027f2bd108e56edfa41 Mon Sep 17 00:00:00 2001 From: Koen Schmeets Date: Wed, 6 Sep 2023 22:35:35 +0200 Subject: [PATCH 08/19] Try to fix install prefix fallback --- install.sh | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/install.sh b/install.sh index 2f25aae3..8b751aa9 100755 --- a/install.sh +++ b/install.sh @@ -30,9 +30,9 @@ OPTIONS: --boost-architecture Set the architecture for Boost (one of: x86, ia64, sparc, power, loongarch, mips, mips1, mips2, mips3, mips4, mips32, mips32r2, mips64, parisc, arm, riscv, s390x, arm+x86) (only valid when using --install-boost and --boost-with-python) --boost-python-version Set the python version to look for when compiling Boost (only valid when using --install-boost and --boost-with-python) - --python-executable Set a custom path (or name of) the Python executable (only valid when using --build-library python) - --python-prefix Set the python prefix, this will be passed to CMake as Python3_ROOT_DIR, to make sure CMake is using the correct Python installation. (only valid when using --build-library python) - --python-pip-install Uses "pip install ." to compile and install the Python library (only valid when using --build-library python) + --python-executable Set a custom path (or name of) the Python executable + --python-prefix Set the python prefix, this will be passed to CMake as Python3_ROOT_DIR, to make sure CMake is using the correct Python installation. + --python-pip-install Uses "pip install ." to compile and install the Python library --platform Set the platform, for when auto-detection doesn't work (one of: windows, macos, linux) @@ -84,7 +84,6 @@ positional_args=() while [[ "$#" -gt 0 ]]; do case $1 in --clean) OCL_CLEAN="1"; ;; - --build-library) OCL_BUILD_LIBRARY="$2"; shift ;; --build-type) OCL_BUILD_TYPE="$2"; shift ;; --platform) OCL_PLATFORM="$2"; shift ;; --install-system-deps) OCL_INSTALL_SYSTEM_DEPS="1"; ;; @@ -125,9 +124,6 @@ if [[ ${#positional_args[@]} != 1 ]]; then fi OCL_BUILD_LIBRARY="${positional_args[0]}" -if [[ "${OCL_BUILD_LIBRARY}" == "cxx" ]]; then - OCL_SUDO_INSTALL="1" -fi verify_args() { if [ -n "${OCL_INSTALL_PREFIX}" ] && [ -z "${OCL_INSTALL}" ] && [ -z "${OCL_SUDO_INSTALL}" ]; then @@ -448,13 +444,13 @@ build_nodejslib() { set -x determined_arch=$(node -p 'process.arch') install_prefix_fallback="${project_dir}/src/npmpackage/build/Release/${determined_os}-nodejs-${determined_arch}" + OCL_INSTALL_PREFIX="${OCL_INSTALL_PREFIX:-"${install_prefix_fallback}"}" src/nodejslib/node_modules/.bin/cmake-js \ build \ $(get_cmakejs_args) \ --parallel "${num_procs}" \ ${OCL_NODE_ARCH:+"--arch=${OCL_NODE_ARCH}"} \ --CDBUILD_NODEJS_LIB="ON" \ - --CDCMAKE_INSTALL_PREFIX="${OCL_INSTALL_PREFIX:-"${install_prefix_fallback}"}" \ --config "${build_type}" set +x (cd "${build_dir}" && cmake_install) @@ -501,11 +497,11 @@ build_emscriptenlib() { source "${project_dir}/../emsdk/emsdk_env.sh" set -x install_prefix_fallback="${project_dir}/src/npmpackage/build" + OCL_INSTALL_PREFIX="${OCL_INSTALL_PREFIX:-"${install_prefix_fallback}"}" emcmake cmake $(get_cmake_args) \ -D BUILD_EMSCRIPTEN_LIB="ON" \ -D USE_OPENMP="OFF" \ - -D USE_STATIC_BOOST="ON" \ - -D CMAKE_INSTALL_PREFIX="${OCL_INSTALL_PREFIX:-"${install_prefix_fallback}"}" + -D USE_STATIC_BOOST="ON" cd "${build_dir}" if [ "${determined_os}" = "windows" ]; then emmake make \ From 07bc2ee44611b7dc914bb7146e93eddcf1e53577 Mon Sep 17 00:00:00 2001 From: Koen Schmeets Date: Wed, 6 Sep 2023 22:57:03 +0200 Subject: [PATCH 09/19] Debug windows issue --- .github/workflows/test.yml | 11 ++--------- install.sh | 4 +--- 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d0bde765..2e5081fa 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -113,19 +113,12 @@ jobs: - name: Install shell: bash run: | - if [ "${{ matrix.os_short }}" == "linux" ]; then - export OCL_INSTALL_BOOST="1" - export OCL_BOOST_WITH_PYTHON="1" - export OCL_BOOST_PREFIX="$(pwd)" - else - export OCL_INSTALL_BOOST_FROM_REPO="1" - fi ./install.sh \ --build-type release \ --install-system-deps \ --python-executable python \ - --python-pip-install \ --test \ - python + python || ls -lah /c/hostedtoolcache/windows/Python/3.10.11/x64/lib/site-packages/opencamlib + fi env: CMAKE_GENERATOR: ${{ matrix.cmake_generator }} diff --git a/install.sh b/install.sh index 8b751aa9..241019bf 100755 --- a/install.sh +++ b/install.sh @@ -32,8 +32,7 @@ OPTIONS: --python-executable Set a custom path (or name of) the Python executable --python-prefix Set the python prefix, this will be passed to CMake as Python3_ROOT_DIR, to make sure CMake is using the correct Python installation. - --python-pip-install Uses "pip install ." to compile and install the Python library - + --platform Set the platform, for when auto-detection doesn't work (one of: windows, macos, linux) --macos-architecture Set the macOS architecture to compile for (one of: arm64, x86_64), useful for cross compiling. @@ -105,7 +104,6 @@ while [[ "$#" -gt 0 ]]; do --cmake-generator-platform) OCL_GENERATOR_PLATFORM="$2"; shift ;; --python-executable) OCL_PYTHON_EXECUTABLE="$2"; shift ;; --python-prefix) OCL_PYTHON_PREFIX="$2"; shift ;; - --python-pip-install) OCL_PYTHON_PIP_INSTALL="1"; ;; --node-architecture) OCL_NODE_ARCH="$2"; shift ;; --test) OCL_TEST="1"; ;; --help|--*) From d3d66f834c4eeae443cc444bf7a1ca0f555850b5 Mon Sep 17 00:00:00 2001 From: Koen Schmeets Date: Wed, 6 Sep 2023 23:31:38 +0200 Subject: [PATCH 10/19] Vebose debug --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 2e5081fa..c2d202d3 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -118,7 +118,7 @@ jobs: --install-system-deps \ --python-executable python \ --test \ - python || ls -lah /c/hostedtoolcache/windows/Python/3.10.11/x64/lib/site-packages/opencamlib + python || (cd /c/hostedtoolcache/windows/Python/3.10.11/x64/lib/site-packages/opencamlib && ls -lah && dumpbin /dependents ocl.pyd) fi env: CMAKE_GENERATOR: ${{ matrix.cmake_generator }} From 19c3cce98e23e2c642e03064fa37e10c4aedff7a Mon Sep 17 00:00:00 2001 From: Koen Schmeets Date: Thu, 7 Sep 2023 10:37:06 +0200 Subject: [PATCH 11/19] Try installing VCOMP140 --- .github/workflows/test.yml | 3 +-- src/CMakeLists.txt | 4 ++++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c2d202d3..43f5c20a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -118,7 +118,6 @@ jobs: --install-system-deps \ --python-executable python \ --test \ - python || (cd /c/hostedtoolcache/windows/Python/3.10.11/x64/lib/site-packages/opencamlib && ls -lah && dumpbin /dependents ocl.pyd) - fi + python env: CMAKE_GENERATOR: ${{ matrix.cmake_generator }} diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b96b956d..64ea621f 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -161,6 +161,10 @@ if(USE_OPENMP) list(APPEND CMAKE_PREFIX_PATH "/opt/homebrew/opt/libomp") endif() endif() + if(MSVC) + set(CMAKE_INSTALL_OPENMP_LIBRARIES ON) + include(InstallRequiredSystemLibraries) + endif() find_package(OpenMP REQUIRED) if(OPENMP_FOUND) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}") From d719497bf85f54f9cda4cf1b6d0ca24f03f6eb96 Mon Sep 17 00:00:00 2001 From: Koen Schmeets Date: Fri, 8 Sep 2023 08:55:09 +0200 Subject: [PATCH 12/19] See if lld is available on github actions --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 43f5c20a..5b67a396 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -118,6 +118,6 @@ jobs: --install-system-deps \ --python-executable python \ --test \ - python + python || (pip install delvewheel && cd /c/hostedtoolcache/windows/Python/3.10.11/x64/lib/site-packages/opencamlib && ls -lah && && delvewheel show opencamlib || delvewheel show ocl.pyd) env: CMAKE_GENERATOR: ${{ matrix.cmake_generator }} From 2751f87efb3455d26d7758e20bf2336336681913 Mon Sep 17 00:00:00 2001 From: Koen Schmeets Date: Tue, 10 Dec 2024 22:43:01 +0100 Subject: [PATCH 13/19] Fix double && --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 5b67a396..76a2a8b9 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -118,6 +118,6 @@ jobs: --install-system-deps \ --python-executable python \ --test \ - python || (pip install delvewheel && cd /c/hostedtoolcache/windows/Python/3.10.11/x64/lib/site-packages/opencamlib && ls -lah && && delvewheel show opencamlib || delvewheel show ocl.pyd) + python || (pip install delvewheel && cd /c/hostedtoolcache/windows/Python/3.10.11/x64/lib/site-packages/opencamlib && ls -lah && delvewheel show opencamlib || delvewheel show ocl.pyd) env: CMAKE_GENERATOR: ${{ matrix.cmake_generator }} From 77d17fef5baa88584034ef020069ef798a328ee3 Mon Sep 17 00:00:00 2001 From: Koen Schmeets Date: Tue, 10 Dec 2024 23:06:03 +0100 Subject: [PATCH 14/19] Try to use FindBoost from config --- src/CMakeLists.txt | 2 +- src/pythonlib/pythonlib.cmake | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 64ea621f..a9de46a3 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -139,7 +139,7 @@ if(BUILD_EMSCRIPTEN_LIB) set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE BOTH) set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE BOTH) endif() -find_package(Boost REQUIRED) +find_package(Boost CONFIG REQUIRED) include_directories(${Boost_INCLUDE_DIRS}) if(BUILD_EMSCRIPTEN_LIB) set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) diff --git a/src/pythonlib/pythonlib.cmake b/src/pythonlib/pythonlib.cmake index 61645076..e567c332 100644 --- a/src/pythonlib/pythonlib.cmake +++ b/src/pythonlib/pythonlib.cmake @@ -4,7 +4,7 @@ if(Python3_FOUND) message(STATUS "Python libraries: " ${Python3_LIBRARIES}) message(STATUS "Python executable: " ${Python3_EXECUTABLE}) endif() -find_package(Boost COMPONENTS python${Python3_VERSION_MAJOR}${Python3_VERSION_MINOR} REQUIRED) +find_package(Boost CONFIG COMPONENTS python${Python3_VERSION_MAJOR}${Python3_VERSION_MINOR} REQUIRED) # include dirs include_directories(${PROJECT_SOURCE_DIR}/cutters) From 1ec6d2f3430c8a041ad12c6f701921efb36acae8 Mon Sep 17 00:00:00 2001 From: Koen Schmeets Date: Tue, 10 Dec 2024 23:20:19 +0100 Subject: [PATCH 15/19] Try Boost_DIR --- .github/workflows/cd.yml | 12 ++++++------ README.rst | 8 ++++---- install.sh | 6 +++--- src/CMakeLists.txt | 2 +- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 1a163753..b1e5a981 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -286,25 +286,25 @@ jobs: CIBW_BUILD_VERBOSITY: "1" CIBW_ARCHS_WINDOWS: "${{ matrix.cibuildwheel_architecture }}" CIBW_ENVIRONMENT_WINDOWS: > - BOOST_ROOT="$(cygpath -w $(pwd))" + Boost_DIR="$(cygpath -w $(pwd))" OCL_BOOST_ADDRESS_MODEL="${{ matrix.boost_address_model }}" OCL_BOOST_ARCHITECTURE="${{ matrix.boost_architecture }}" CMAKE_GENERATOR="Visual Studio 17 2022" CMAKE_GENERATOR_PLATFORM="${{ matrix.cmake_generator_platform }}" - CIBW_ENVIRONMENT_PASS_WINDOWS: "BOOST_ROOT OCL_BOOST_ADDRESS_MODEL OCL_BOOST_ARCHITECTURE CMAKE_GENERATOR CMAKE_GENERATOR_PLATFORM" + CIBW_ENVIRONMENT_PASS_WINDOWS: "Boost_DIR OCL_BOOST_ADDRESS_MODEL OCL_BOOST_ARCHITECTURE CMAKE_GENERATOR CMAKE_GENERATOR_PLATFORM" CIBW_ARCHS_MACOS: "${{ matrix.architecture }}" CIBW_ENVIRONMENT_MACOS: > - BOOST_ROOT="$(pwd)" + Boost_DIR="$(pwd)" OCL_MACOS_ARCHITECTURE="${{ matrix.architecture }}" OCL_BOOST_ARCHITECTURE="${{ matrix.boost_architecture }}" OPENMP_PREFIX_MACOS="/tmp/libomp/libomp/fixed" - CIBW_ENVIRONMENT_PASS_MACOS: "BOOST_ROOT OCL_BOOST_ARCHITECTURE OPENMP_PREFIX_MACOS" + CIBW_ENVIRONMENT_PASS_MACOS: "Boost_DIR OCL_BOOST_ARCHITECTURE OPENMP_PREFIX_MACOS" CIBW_ARCHS_LINUX: "${{ matrix.architecture }}" CIBW_ENVIRONMENT_LINUX: > - BOOST_ROOT="$(pwd)" + Boost_DIR="$(pwd)" OCL_BOOST_ARCHITECTURE="${{ matrix.boost_architecture }}" CMAKE_GENERATOR="Unix Makefiles" - CIBW_ENVIRONMENT_PASS_LINUX: "BOOST_ROOT OCL_BOOST_ARCHITECTURE CMAKE_GENERATOR" + CIBW_ENVIRONMENT_PASS_LINUX: "Boost_DIR OCL_BOOST_ARCHITECTURE CMAKE_GENERATOR" # - name: Compress Boost.Python # shell: bash # run: | diff --git a/README.rst b/README.rst index 0648bd8e..83ce3761 100644 --- a/README.rst +++ b/README.rst @@ -204,7 +204,7 @@ Make sure you have a compiler, git, cmake and Boost installed (or simply downloa make . # try make -j4 for a faster build if you have a multi-core machine make install . -When boost is not in a standard location, you can add the ``-D BOOST_ROOT=/path/to/boost`` option to the cmake command. +When boost is not in a standard location, you can add the ``-D Boost_DIR=/path/to/boost`` option to the cmake command. ======================= Building for Emscripten @@ -233,7 +233,7 @@ Now you can compile OpenCAMLib like this (make sure to replace the ``path/to/`` -D BUILD_EMSCRIPTEN_LIB="ON" \ -D USE_OPENMP="OFF" \ -D CMAKE_INSTALL_PREFIX="/path/to/opencamlib/src/npmpackage/build" \ - -D BOOST_ROOT="/path/to/boost" \ + -D Boost_DIR="/path/to/boost" \ .. emmake make # try emmake make -j4 for a faster build if you have a multi-core machine @@ -266,7 +266,7 @@ Next, use cmake-js to compile the library: --CDBUILD_NODEJS_LIB="ON" \ --CDUSE_OPENMP="ON" \ --CDCMAKE_INSTALL_PREFIX="/path/to/opencamlib/build/Release/$(node --print 'process.platform')-nodejs-$(node --print 'process.arch')" \ - --CDBOOST_ROOT="/path/to/boost" \ + --CDBoost_DIR="/path/to/boost" \ --config "Release" =================== @@ -337,7 +337,7 @@ This happens a lot, here are some of the reasons why this happens: If you forgot to install boost, go ahead and download Boost from from their website: https://www.boost.org/users/download/ and extract it somewhere. Now, when compiling the C++ or node.js module, add the -``-D BOOST_ROOT=/path/to/extracted/boost`` flag to the ``cmake ..`` command, or the. +``-D Boost_DIR=/path/to/extracted/boost`` flag to the ``cmake ..`` command, or the. ``--boost-prefix /path/to/extracted/boost`` flag to the ``./install.sh`` command diff --git a/install.sh b/install.sh index 241019bf..76569ec9 100755 --- a/install.sh +++ b/install.sh @@ -400,7 +400,7 @@ get_cmake_args() { -D VERSION_STRING="2023.09.6" ${OCL_DISABLE_OPENMP:+"-D USE_OPENMP=OFF"} \ ${OCL_INSTALL_PREFIX:+"-D CMAKE_INSTALL_PREFIX=${OCL_INSTALL_PREFIX}"} \ - ${OCL_BOOST_PREFIX:+"-D BOOST_ROOT=${OCL_BOOST_PREFIX}"}" + ${OCL_BOOST_PREFIX:+"-D Boost_DIR=${OCL_BOOST_PREFIX}"}" } get_cmakejs_args() { @@ -427,7 +427,7 @@ test_cxxlib() { ${OCL_GENERATOR:+"-G ${OCL_GENERATOR}"} \ ${OCL_GENERATOR_PLATFORM:+"-A ${OCL_GENERATOR_PLATFORM}"} \ -D Boost_ADDITIONAL_VERSIONS="${boost_additional_versions}" \ - ${OCL_BOOST_PREFIX:+"-DBOOST_ROOT=${OCL_BOOST_PREFIX}"} + ${OCL_BOOST_PREFIX:+"-DBoost_DIR=${OCL_BOOST_PREFIX}"} set +x cd build cmake_build @@ -480,7 +480,7 @@ build_pythonlib() { export CMAKE_ARGS="${OCL_GENERATOR:+"-G ${OCL_GENERATOR} "}\ ${OCL_GENERATOR_PLATFORM:+"-A ${OCL_GENERATOR_PLATFORM} "}\ -D CMAKE_BUILD_TYPE=${build_type} \ -${OCL_BOOST_PREFIX:+"-D BOOST_ROOT=${OCL_BOOST_PREFIX} "}" +${OCL_BOOST_PREFIX:+"-D Boost_DIR=${OCL_BOOST_PREFIX} "}" cd "${project_dir}" ${python_executable} -m pip install --verbose . } diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index a9de46a3..877bf52d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -109,7 +109,7 @@ set(Boost_DEBUG ON CACHE BOOL "boost-debug") if(USE_STATIC_BOOST) set(Boost_USE_STATIC_LIBS ON CACHE BOOL "boost-use-static-libs") endif() -if(DEFINED ENV{BOOST_ROOT} OR DEFINED BOOST_ROOT) +if(DEFINED ENV{Boost_DIR} OR DEFINED Boost_DIR) set(Boost_NO_SYSTEM_PATHS ON) endif() if(CMAKE_BUILD_TYPE MATCHES Debug) From fa230767a7a48c7800279f13f8ba54af72ac395c Mon Sep 17 00:00:00 2001 From: Koen Schmeets Date: Wed, 11 Dec 2024 00:04:27 +0100 Subject: [PATCH 16/19] Revert "Try Boost_DIR" This reverts commit 1ec6d2f3430c8a041ad12c6f701921efb36acae8. --- .github/workflows/cd.yml | 12 ++++++------ README.rst | 8 ++++---- install.sh | 6 +++--- src/CMakeLists.txt | 2 +- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index b1e5a981..1a163753 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -286,25 +286,25 @@ jobs: CIBW_BUILD_VERBOSITY: "1" CIBW_ARCHS_WINDOWS: "${{ matrix.cibuildwheel_architecture }}" CIBW_ENVIRONMENT_WINDOWS: > - Boost_DIR="$(cygpath -w $(pwd))" + BOOST_ROOT="$(cygpath -w $(pwd))" OCL_BOOST_ADDRESS_MODEL="${{ matrix.boost_address_model }}" OCL_BOOST_ARCHITECTURE="${{ matrix.boost_architecture }}" CMAKE_GENERATOR="Visual Studio 17 2022" CMAKE_GENERATOR_PLATFORM="${{ matrix.cmake_generator_platform }}" - CIBW_ENVIRONMENT_PASS_WINDOWS: "Boost_DIR OCL_BOOST_ADDRESS_MODEL OCL_BOOST_ARCHITECTURE CMAKE_GENERATOR CMAKE_GENERATOR_PLATFORM" + CIBW_ENVIRONMENT_PASS_WINDOWS: "BOOST_ROOT OCL_BOOST_ADDRESS_MODEL OCL_BOOST_ARCHITECTURE CMAKE_GENERATOR CMAKE_GENERATOR_PLATFORM" CIBW_ARCHS_MACOS: "${{ matrix.architecture }}" CIBW_ENVIRONMENT_MACOS: > - Boost_DIR="$(pwd)" + BOOST_ROOT="$(pwd)" OCL_MACOS_ARCHITECTURE="${{ matrix.architecture }}" OCL_BOOST_ARCHITECTURE="${{ matrix.boost_architecture }}" OPENMP_PREFIX_MACOS="/tmp/libomp/libomp/fixed" - CIBW_ENVIRONMENT_PASS_MACOS: "Boost_DIR OCL_BOOST_ARCHITECTURE OPENMP_PREFIX_MACOS" + CIBW_ENVIRONMENT_PASS_MACOS: "BOOST_ROOT OCL_BOOST_ARCHITECTURE OPENMP_PREFIX_MACOS" CIBW_ARCHS_LINUX: "${{ matrix.architecture }}" CIBW_ENVIRONMENT_LINUX: > - Boost_DIR="$(pwd)" + BOOST_ROOT="$(pwd)" OCL_BOOST_ARCHITECTURE="${{ matrix.boost_architecture }}" CMAKE_GENERATOR="Unix Makefiles" - CIBW_ENVIRONMENT_PASS_LINUX: "Boost_DIR OCL_BOOST_ARCHITECTURE CMAKE_GENERATOR" + CIBW_ENVIRONMENT_PASS_LINUX: "BOOST_ROOT OCL_BOOST_ARCHITECTURE CMAKE_GENERATOR" # - name: Compress Boost.Python # shell: bash # run: | diff --git a/README.rst b/README.rst index 83ce3761..0648bd8e 100644 --- a/README.rst +++ b/README.rst @@ -204,7 +204,7 @@ Make sure you have a compiler, git, cmake and Boost installed (or simply downloa make . # try make -j4 for a faster build if you have a multi-core machine make install . -When boost is not in a standard location, you can add the ``-D Boost_DIR=/path/to/boost`` option to the cmake command. +When boost is not in a standard location, you can add the ``-D BOOST_ROOT=/path/to/boost`` option to the cmake command. ======================= Building for Emscripten @@ -233,7 +233,7 @@ Now you can compile OpenCAMLib like this (make sure to replace the ``path/to/`` -D BUILD_EMSCRIPTEN_LIB="ON" \ -D USE_OPENMP="OFF" \ -D CMAKE_INSTALL_PREFIX="/path/to/opencamlib/src/npmpackage/build" \ - -D Boost_DIR="/path/to/boost" \ + -D BOOST_ROOT="/path/to/boost" \ .. emmake make # try emmake make -j4 for a faster build if you have a multi-core machine @@ -266,7 +266,7 @@ Next, use cmake-js to compile the library: --CDBUILD_NODEJS_LIB="ON" \ --CDUSE_OPENMP="ON" \ --CDCMAKE_INSTALL_PREFIX="/path/to/opencamlib/build/Release/$(node --print 'process.platform')-nodejs-$(node --print 'process.arch')" \ - --CDBoost_DIR="/path/to/boost" \ + --CDBOOST_ROOT="/path/to/boost" \ --config "Release" =================== @@ -337,7 +337,7 @@ This happens a lot, here are some of the reasons why this happens: If you forgot to install boost, go ahead and download Boost from from their website: https://www.boost.org/users/download/ and extract it somewhere. Now, when compiling the C++ or node.js module, add the -``-D Boost_DIR=/path/to/extracted/boost`` flag to the ``cmake ..`` command, or the. +``-D BOOST_ROOT=/path/to/extracted/boost`` flag to the ``cmake ..`` command, or the. ``--boost-prefix /path/to/extracted/boost`` flag to the ``./install.sh`` command diff --git a/install.sh b/install.sh index 76569ec9..241019bf 100755 --- a/install.sh +++ b/install.sh @@ -400,7 +400,7 @@ get_cmake_args() { -D VERSION_STRING="2023.09.6" ${OCL_DISABLE_OPENMP:+"-D USE_OPENMP=OFF"} \ ${OCL_INSTALL_PREFIX:+"-D CMAKE_INSTALL_PREFIX=${OCL_INSTALL_PREFIX}"} \ - ${OCL_BOOST_PREFIX:+"-D Boost_DIR=${OCL_BOOST_PREFIX}"}" + ${OCL_BOOST_PREFIX:+"-D BOOST_ROOT=${OCL_BOOST_PREFIX}"}" } get_cmakejs_args() { @@ -427,7 +427,7 @@ test_cxxlib() { ${OCL_GENERATOR:+"-G ${OCL_GENERATOR}"} \ ${OCL_GENERATOR_PLATFORM:+"-A ${OCL_GENERATOR_PLATFORM}"} \ -D Boost_ADDITIONAL_VERSIONS="${boost_additional_versions}" \ - ${OCL_BOOST_PREFIX:+"-DBoost_DIR=${OCL_BOOST_PREFIX}"} + ${OCL_BOOST_PREFIX:+"-DBOOST_ROOT=${OCL_BOOST_PREFIX}"} set +x cd build cmake_build @@ -480,7 +480,7 @@ build_pythonlib() { export CMAKE_ARGS="${OCL_GENERATOR:+"-G ${OCL_GENERATOR} "}\ ${OCL_GENERATOR_PLATFORM:+"-A ${OCL_GENERATOR_PLATFORM} "}\ -D CMAKE_BUILD_TYPE=${build_type} \ -${OCL_BOOST_PREFIX:+"-D Boost_DIR=${OCL_BOOST_PREFIX} "}" +${OCL_BOOST_PREFIX:+"-D BOOST_ROOT=${OCL_BOOST_PREFIX} "}" cd "${project_dir}" ${python_executable} -m pip install --verbose . } diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 877bf52d..a9de46a3 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -109,7 +109,7 @@ set(Boost_DEBUG ON CACHE BOOL "boost-debug") if(USE_STATIC_BOOST) set(Boost_USE_STATIC_LIBS ON CACHE BOOL "boost-use-static-libs") endif() -if(DEFINED ENV{Boost_DIR} OR DEFINED Boost_DIR) +if(DEFINED ENV{BOOST_ROOT} OR DEFINED BOOST_ROOT) set(Boost_NO_SYSTEM_PATHS ON) endif() if(CMAKE_BUILD_TYPE MATCHES Debug) From 6f1d28fcf4609a9d8f145d697e22d73b2c1ad534 Mon Sep 17 00:00:00 2001 From: Koen Schmeets Date: Wed, 11 Dec 2024 00:05:05 +0100 Subject: [PATCH 17/19] CMP0167 old --- src/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index a9de46a3..0b6a9ecc 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -9,6 +9,7 @@ if(COMMAND cmake_policy) cmake_policy(SET CMP0094 NEW) # for Python*_FIND_STRATEGY=LOCATION cmake_policy(SET CMP0042 NEW) cmake_policy(SET CMP0054 NEW) + cmake_policy(SET CMP0167 OLD) endif(COMMAND cmake_policy) # install targets in root of the build dir, using $<0:> generator expression to force it from not being overwritten From 29169d012775fcceea670099d800ede980ca98f8 Mon Sep 17 00:00:00 2001 From: Koen Schmeets Date: Wed, 11 Dec 2024 01:03:08 +0100 Subject: [PATCH 18/19] CMP0144 new --- src/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 0b6a9ecc..ee1cda26 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -9,6 +9,7 @@ if(COMMAND cmake_policy) cmake_policy(SET CMP0094 NEW) # for Python*_FIND_STRATEGY=LOCATION cmake_policy(SET CMP0042 NEW) cmake_policy(SET CMP0054 NEW) + cmake_policy(SET CMP0144 NEW) cmake_policy(SET CMP0167 OLD) endif(COMMAND cmake_policy) From f6b1ba393233b04a363f5bd37000b0e15a6f81ed Mon Sep 17 00:00:00 2001 From: Koen Schmeets Date: Wed, 11 Dec 2024 03:54:46 +0100 Subject: [PATCH 19/19] Noconfig --- src/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index ee1cda26..89780051 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -141,7 +141,7 @@ if(BUILD_EMSCRIPTEN_LIB) set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE BOTH) set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE BOTH) endif() -find_package(Boost CONFIG REQUIRED) +find_package(Boost REQUIRED) include_directories(${Boost_INCLUDE_DIRS}) if(BUILD_EMSCRIPTEN_LIB) set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)