Skip to content

Commit

Permalink
Make shared boost the default, simpler VERSION_STRING, fix Doxygen
Browse files Browse the repository at this point in the history
  • Loading branch information
vespakoen committed Aug 29, 2023
1 parent 7149b04 commit 21b1432
Show file tree
Hide file tree
Showing 11 changed files with 37 additions and 118 deletions.
4 changes: 4 additions & 0 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}"} \
Expand Down Expand Up @@ -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"} \
Expand Down Expand Up @@ -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"} \
Expand Down Expand Up @@ -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}"} \
Expand Down
43 changes: 7 additions & 36 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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(
Expand Down
11 changes: 5 additions & 6 deletions src/Doxyfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions src/cxxlib/cxxlib.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions src/emscriptenlib/emscriptenlib.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
5 changes: 5 additions & 0 deletions src/nodejslib/nodejslib.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
1 change: 0 additions & 1 deletion src/ocl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
#ifdef _OPENMP
#include <omp.h>
#endif
#include "version_string.hpp"

namespace ocl
{
Expand Down
4 changes: 4 additions & 0 deletions src/ocl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@

#include <string>

#ifndef VERSION_STRING
#define VERSION_STRING "unknown-version"
#endif

namespace ocl
{
int max_threads();
Expand Down
2 changes: 0 additions & 2 deletions src/pythonlib/ocl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@
#include <boost/python.hpp>
#include <boost/python/docstring_options.hpp>

#include "version_string.hpp" // autogenerated by version_string.cmake

std::string ocl_docstring() {
return "OpenCAMLib docstring";
}
Expand Down
4 changes: 4 additions & 0 deletions src/pythonlib/pythonlib.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
73 changes: 0 additions & 73 deletions src/version_string.cmake

This file was deleted.

0 comments on commit 21b1432

Please sign in to comment.