Skip to content

Commit

Permalink
Merge pull request #412 from ralfkonrad/feature/make-boost-andswig-ve…
Browse files Browse the repository at this point in the history
…rsions-configurable

Make the versions of Boost and Swig configurable via setting a cache entry for them
  • Loading branch information
ralfkonrad authored Oct 5, 2024
2 parents 163d08f + 15bc750 commit fb8083c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 17 deletions.
37 changes: 21 additions & 16 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,30 +16,35 @@ endif ()

project(quantlib_for_maven VERSION 1.35.0 LANGUAGES CXX)

# set the Boost and Swig versions we want to use
# to ensure compatibility across linux, macos and windows builds
set(RKE_BOOST_VERSION "1.86.0" CACHE STRING "Boost version we want to use to ensure compatibility")
set(RKE_SWIG_VERSION "4.2.1" CACHE STRING "Swig version we want to use to ensure compatibility")

# set the QuantLib options the way we need them.
# So, they do not need to be provided in the presets or as a cmake -D cache entry.
set(QL_ENABLE_THREAD_SAFE_OBSERVER_PATTERN ON CACHE BOOL "Needed for java's garbage collector" FORCE)
set(QL_THROW_IN_CYCLES ON CACHE BOOL "" FORCE)
set(QL_FASTER_LAZY_OBJECTS OFF CACHE BOOL "" FORCE)
set(QL_ENABLE_THREAD_SAFE_OBSERVER_PATTERN ON CACHE BOOL "Needed for java's garbage collector" FORCE)
set(QL_THROW_IN_CYCLES ON CACHE BOOL "Throw an exception when a notification loop is detected")
set(QL_FASTER_LAZY_OBJECTS OFF CACHE BOOL "Cause lazy objects to forward just the first notification instead of every one")

# paths needed throughout the build
cmake_path(SET QUANTLIB_ROOT external/QuantLib)
cmake_path(SET QUANTLIB_ROOT external/QuantLib)

cmake_path(SET QUANTLIB_ROOT_DIR ${CMAKE_SOURCE_DIR}/${QUANTLIB_ROOT})
cmake_path(SET QUANTLIB_GENERATED_HEADERS_DIR ${CMAKE_BINARY_DIR}/${QUANTLIB_ROOT})
cmake_path(SET QUANTLIB_ROOT_DIR ${CMAKE_SOURCE_DIR}/${QUANTLIB_ROOT})
cmake_path(SET QUANTLIB_GENERATED_HEADERS_DIR ${CMAKE_BINARY_DIR}/${QUANTLIB_ROOT})

cmake_path(SET QUANTLIB_SWIG_ROOT_DIR ${CMAKE_SOURCE_DIR}/external/QuantLib-SWIG/SWIG)
cmake_path(SET QUANTLIB_SWIG_ROOT_DIR ${CMAKE_SOURCE_DIR}/external/QuantLib-SWIG/SWIG)

cmake_path(SET SWIG_ROOT swig)
cmake_path(SET QL_ENTRYPOINT_I_FILE ${CMAKE_SOURCE_DIR}/${SWIG_ROOT}/QuantLibEntrypoint.i)
cmake_path(SET SWIG_ROOT swig)
cmake_path(SET QL_ENTRYPOINT_I_FILE ${CMAKE_SOURCE_DIR}/${SWIG_ROOT}/QuantLibEntrypoint.i)

cmake_path(SET SWIG_CPP_DIR ${CMAKE_BINARY_DIR}/cpp)
cmake_path(SET SWIG_CPP_DIR ${CMAKE_BINARY_DIR}/cpp)

cmake_path(SET SWIG_JAVA_DIR ${CMAKE_SOURCE_DIR}/java)
cmake_path(SET SWIG_JAVA_SRC_DIR ${SWIG_JAVA_DIR}/src/main)
cmake_path(SET SWIG_JAVA_PACKAGE_DIR ${SWIG_JAVA_SRC_DIR}/java/org/quantlib)
cmake_path(SET SWIG_JAVA_RESOURCES_DIR ${SWIG_JAVA_SRC_DIR}/resources)
cmake_path(SET SWIG_JAVA_TARGET_DIR ${SWIG_JAVA_DIR}/target)
cmake_path(SET SWIG_JAVA_DIR ${CMAKE_SOURCE_DIR}/java)
cmake_path(SET SWIG_JAVA_SRC_DIR ${SWIG_JAVA_DIR}/src/main)
cmake_path(SET SWIG_JAVA_PACKAGE_DIR ${SWIG_JAVA_SRC_DIR}/java/org/quantlib)
cmake_path(SET SWIG_JAVA_RESOURCES_DIR ${SWIG_JAVA_SRC_DIR}/resources)
cmake_path(SET SWIG_JAVA_TARGET_DIR ${SWIG_JAVA_DIR}/target)

# Path for package-local cmake modules
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
Expand All @@ -58,7 +63,7 @@ if (${MSVC})
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
endif ()

find_package(Boost 1.86.0 EXACT CONFIG REQUIRED)
find_package(Boost ${RKE_BOOST_VERSION} EXACT CONFIG REQUIRED)

add_subdirectory(${QUANTLIB_ROOT})
add_subdirectory(${SWIG_ROOT})
2 changes: 1 addition & 1 deletion swig/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ find_package(Threads REQUIRED)

find_package(JNI REQUIRED)

find_package(SWIG 4.2.1 EXACT REQUIRED COMPONENTS java)
find_package(SWIG ${RKE_SWIG_VERSION} EXACT REQUIRED COMPONENTS java)
include(UseSWIG)

set_property(SOURCE ${QL_ENTRYPOINT_I_FILE} PROPERTY CPLUSPLUS ON)
Expand Down

0 comments on commit fb8083c

Please sign in to comment.