diff --git a/CMakeLists.txt b/CMakeLists.txt index 27a49a6..2c211d9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) @@ -58,7 +63,7 @@ if (${MSVC}) set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$: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}) diff --git a/swig/CMakeLists.txt b/swig/CMakeLists.txt index 2594a88..86f7de8 100644 --- a/swig/CMakeLists.txt +++ b/swig/CMakeLists.txt @@ -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)