From a0cc5cf420669d65298a15c656f22ce15b5489c4 Mon Sep 17 00:00:00 2001 From: francis Date: Wed, 26 Nov 2025 12:45:37 +0000 Subject: [PATCH 01/18] Allow users to have an untracked CMakeUserPresets.json file. --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 9b4696c85..64b461df3 100644 --- a/.gitignore +++ b/.gitignore @@ -350,4 +350,4 @@ Examples/**/pricingstats.csv *.fls .gitmodules - +CMakeUserPresets.json From a8e98c40af1cb6dc085946c63f746c09ddeebb98 Mon Sep 17 00:00:00 2001 From: francis Date: Wed, 26 Nov 2025 15:24:03 +0000 Subject: [PATCH 02/18] Add Boost libraries missing in link step. When find_package uses config search mode for Boost instead of the old module search mode, there are Boost libraries missing in the link step: - Boost::log_setup missing for QLE and ORED test suites. - Boost::regex missing in ORE-SWIG build. To build using the CMake config file provided by Boost, you do not create the BOOST and BOOST_LIB64 environment variables and hence BOOST_INCLUDEDIR and BOOST_LIBRARYDIR are not set in the presets. You instead supply the path to BoostConfig.cmake in the variable Boost_DIR. Also, if you are using CMake 3.30 and above, you should set the variable CMAKE_POLICY_DEFAULT_CMP0167 to NEW to avoid warnings about the policy not being set. This issue is not apparent when you create the BOOST and BOOST_LIB64 environment variables because CMake uses the module mode search and the CMake FindBoost.cmake module has entries of the form: set(_Boost_LOG_DEPENDENCIES log_setup regex ...) so the dependencies on log_setup and regex are pulled in. Note: to see the difference in the link commands, you need to keep the .rsp files that are used to store the .obj and .lib file arguments. If building with Ninja, you can do this by passing `-d keeprsp` to the build step. From command line, something like this for example: cmake --build --preset=windows-ninja-x64-debug --target quantext-test-suite.exe --verbose -- -d keeprsp or if you want to add it to the preset file for VS to pick up: "nativeToolOptions": [ "-d keeprsp" ] --- ORE-SWIG/CMakeLists.txt | 2 +- OREData/CMakeLists.txt | 2 +- QuantExt/CMakeLists.txt | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ORE-SWIG/CMakeLists.txt b/ORE-SWIG/CMakeLists.txt index 377c81000..f909fbcf4 100644 --- a/ORE-SWIG/CMakeLists.txt +++ b/ORE-SWIG/CMakeLists.txt @@ -32,7 +32,7 @@ get_library_name("QuantExt" QLE_LIB_NAME) set_ql_library_name() # To build the module, we moreover need Boost, Swig, Python -set(BOOST_COMPONENT_LIST serialization date_time filesystem timer thread log) +set(BOOST_COMPONENT_LIST serialization date_time filesystem timer thread log regex) if(ORE_USE_ZLIB) diff --git a/OREData/CMakeLists.txt b/OREData/CMakeLists.txt index acfb5aa80..5d866dea7 100644 --- a/OREData/CMakeLists.txt +++ b/OREData/CMakeLists.txt @@ -14,7 +14,7 @@ else() SET(COMPONENTS_CONDITIONAL "") endif() -find_package (Boost REQUIRED COMPONENTS ${COMPONENTS_CONDITIONAL} date_time thread serialization timer log filesystem OPTIONAL_COMPONENTS system chrono) +find_package (Boost REQUIRED COMPONENTS ${COMPONENTS_CONDITIONAL} date_time thread serialization timer log_setup log filesystem OPTIONAL_COMPONENTS system chrono) include_directories(${Boost_INCLUDE_DIRS}) diff --git a/QuantExt/CMakeLists.txt b/QuantExt/CMakeLists.txt index 78253c3e1..e0bce3463 100644 --- a/QuantExt/CMakeLists.txt +++ b/QuantExt/CMakeLists.txt @@ -14,7 +14,7 @@ else() endif() -find_package (Boost REQUIRED COMPONENTS ${COMPONENTS_CONDITIONAL} date_time thread serialization timer log filesystem OPTIONAL_COMPONENTS system chrono) +find_package (Boost REQUIRED COMPONENTS ${COMPONENTS_CONDITIONAL} date_time thread serialization timer log_setup log filesystem OPTIONAL_COMPONENTS system chrono) if (ORE_ENABLE_PARALLEL_UNIT_TEST_RUNNER AND UNIX AND NOT APPLE) From a941b2158eb4c3de69540cd18ce0c2dff6d24925 Mon Sep 17 00:00:00 2001 From: francis Date: Fri, 28 Nov 2025 12:21:55 +0000 Subject: [PATCH 03/18] Respect the BOOST_ALL_NO_LIB variable setting. As is done in QuantLib, if BOOST_ALL_NO_LIB is set, do not include any auto_link.hpp files. In other words, auto linking is turned off and the `/DEFAULTLIB:...` linker directives specifying library names to link against are not written to the .obj files during an MSVC build. --- App/ore.cpp | 2 +- ORE-SWIG/OREAnalytics-SWIG/SWIG/orea.i | 2 +- ORE-SWIG/QuantExt-SWIG/SWIG/ql_patched.i | 2 +- OREAnalytics/orea/orea.hpp | 2 +- OREAnalytics/test/testsuite.cpp | 2 +- OREData/ored/ored.hpp | 2 +- OREData/test/testsuite.cpp | 2 +- ORETest/oret/basedatapath.hpp | 2 +- ORETest/oret/datapaths.hpp | 2 +- ORETest/oret/fileutilities.hpp | 2 +- QuantExt/qle/quantext.hpp | 2 +- QuantExt/test/testsuite.cpp | 2 +- cmake/writeAll.cmake | 2 +- 13 files changed, 13 insertions(+), 13 deletions(-) diff --git a/App/ore.cpp b/App/ore.cpp index 9a481eee3..fbf73f375 100644 --- a/App/ore.cpp +++ b/App/ore.cpp @@ -34,7 +34,7 @@ #include -#ifdef BOOST_MSVC +#if !defined(BOOST_ALL_NO_LIB) && defined(BOOST_MSVC) #include #include #include diff --git a/ORE-SWIG/OREAnalytics-SWIG/SWIG/orea.i b/ORE-SWIG/OREAnalytics-SWIG/SWIG/orea.i index c805d8c25..a6890e2c7 100644 --- a/ORE-SWIG/OREAnalytics-SWIG/SWIG/orea.i +++ b/ORE-SWIG/OREAnalytics-SWIG/SWIG/orea.i @@ -33,7 +33,7 @@ #include -#ifdef BOOST_MSVC +#if !defined(BOOST_ALL_NO_LIB) && defined(BOOST_MSVC) #include #define BOOST_LIB_NAME boost_regex #include diff --git a/ORE-SWIG/QuantExt-SWIG/SWIG/ql_patched.i b/ORE-SWIG/QuantExt-SWIG/SWIG/ql_patched.i index c47d170b4..111c62406 100644 --- a/ORE-SWIG/QuantExt-SWIG/SWIG/ql_patched.i +++ b/ORE-SWIG/QuantExt-SWIG/SWIG/ql_patched.i @@ -84,7 +84,7 @@ #error using an old version of QuantLib, please update #endif -#ifdef BOOST_MSVC +#if !defined(BOOST_ALL_NO_LIB) && defined(BOOST_MSVC) #ifdef QL_ENABLE_THREAD_SAFE_OBSERVER_PATTERN #define BOOST_LIB_NAME boost_thread #include diff --git a/OREAnalytics/orea/orea.hpp b/OREAnalytics/orea/orea.hpp index ed4136a57..8fd3c397d 100644 --- a/OREAnalytics/orea/orea.hpp +++ b/OREAnalytics/orea/orea.hpp @@ -1,7 +1,7 @@ // Autogenerated by cmake // Do not edit -#ifdef BOOST_MSVC +#if !defined(BOOST_ALL_NO_LIB) && defined(BOOST_MSVC) #include #endif diff --git a/OREAnalytics/test/testsuite.cpp b/OREAnalytics/test/testsuite.cpp index 227f3e8a7..55778c57b 100644 --- a/OREAnalytics/test/testsuite.cpp +++ b/OREAnalytics/test/testsuite.cpp @@ -43,7 +43,7 @@ using boost::unit_test::framework::master_test_suite; using ore::test::getBaseDataPath; using ore::test::setupTestLogging; -#ifdef BOOST_MSVC +#if !defined(BOOST_ALL_NO_LIB) && defined(BOOST_MSVC) #include #include #include diff --git a/OREData/ored/ored.hpp b/OREData/ored/ored.hpp index aeb58390a..9fe56c095 100644 --- a/OREData/ored/ored.hpp +++ b/OREData/ored/ored.hpp @@ -1,7 +1,7 @@ // Autogenerated by cmake // Do not edit -#ifdef BOOST_MSVC +#if !defined(BOOST_ALL_NO_LIB) && defined(BOOST_MSVC) #include #endif diff --git a/OREData/test/testsuite.cpp b/OREData/test/testsuite.cpp index 1acb32e5b..2201144dd 100644 --- a/OREData/test/testsuite.cpp +++ b/OREData/test/testsuite.cpp @@ -37,7 +37,7 @@ using boost::unit_test::framework::master_test_suite; using ore::test::getBaseDataPath; using ore::test::setupTestLogging; -#ifdef BOOST_MSVC +#if !defined(BOOST_ALL_NO_LIB) && defined(BOOST_MSVC) #include #include #include diff --git a/ORETest/oret/basedatapath.hpp b/ORETest/oret/basedatapath.hpp index f3d2659d8..3bd52b80a 100644 --- a/ORETest/oret/basedatapath.hpp +++ b/ORETest/oret/basedatapath.hpp @@ -32,7 +32,7 @@ using boost::filesystem::exists; using boost::filesystem::is_directory; using boost::filesystem::path; -#ifdef BOOST_MSVC +#if !defined(BOOST_ALL_NO_LIB) && defined(BOOST_MSVC) #define BOOST_LIB_NAME boost_system #include #define BOOST_LIB_NAME boost_filesystem diff --git a/ORETest/oret/datapaths.hpp b/ORETest/oret/datapaths.hpp index c435c76fc..6b8e5a777 100644 --- a/ORETest/oret/datapaths.hpp +++ b/ORETest/oret/datapaths.hpp @@ -29,7 +29,7 @@ using boost::filesystem::exists; using boost::filesystem::path; using std::string; -#ifdef BOOST_MSVC +#if !defined(BOOST_ALL_NO_LIB) && defined(BOOST_MSVC) #define BOOST_LIB_NAME boost_system #include #define BOOST_LIB_NAME boost_filesystem diff --git a/ORETest/oret/fileutilities.hpp b/ORETest/oret/fileutilities.hpp index 4074926fa..4c2015a3c 100644 --- a/ORETest/oret/fileutilities.hpp +++ b/ORETest/oret/fileutilities.hpp @@ -38,7 +38,7 @@ using std::ifstream; using std::istreambuf_iterator; using std::string; -#ifdef BOOST_MSVC +#if !defined(BOOST_ALL_NO_LIB) && defined(BOOST_MSVC) #define BOOST_LIB_NAME boost_system #include #define BOOST_LIB_NAME boost_filesystem diff --git a/QuantExt/qle/quantext.hpp b/QuantExt/qle/quantext.hpp index 94dc13a53..cfe7007b3 100644 --- a/QuantExt/qle/quantext.hpp +++ b/QuantExt/qle/quantext.hpp @@ -1,7 +1,7 @@ // Autogenerated by cmake // Do not edit -#ifdef BOOST_MSVC +#if !defined(BOOST_ALL_NO_LIB) && defined(BOOST_MSVC) #include #endif diff --git a/QuantExt/test/testsuite.cpp b/QuantExt/test/testsuite.cpp index 31ec80f1a..7500d1c13 100644 --- a/QuantExt/test/testsuite.cpp +++ b/QuantExt/test/testsuite.cpp @@ -50,7 +50,7 @@ using boost::unit_test::framework::master_test_suite; #include "toplevelfixture.hpp" -#ifdef BOOST_MSVC +#if !defined(BOOST_ALL_NO_LIB) && defined(BOOST_MSVC) #include #include #define BOOST_LIB_NAME boost_system diff --git a/cmake/writeAll.cmake b/cmake/writeAll.cmake index d5dade01f..689a1c8f2 100644 --- a/cmake/writeAll.cmake +++ b/cmake/writeAll.cmake @@ -12,7 +12,7 @@ function(writeAll dir output autoLink headers) set(content "// Autogenerated by cmake\n") set(content "${content}// Do not edit\n") set(content "${content}\n") - set(content "${content}#ifdef BOOST_MSVC\n") + set(content "${content}#if !defined(BOOST_ALL_NO_LIB) && defined(BOOST_MSVC)\n") set(content "${content}#include <${dir}/${autoLink}>\n") set(content "${content}#endif\n") set(content "${content}\n") From 97b551473cf1d66f1e220db508a6a0dd315e1dc3 Mon Sep 17 00:00:00 2001 From: francis Date: Fri, 28 Nov 2025 16:31:55 +0000 Subject: [PATCH 04/18] Only include Boost timer when needed. Remove Boost timer where not used and place inside include guard when it is not used outside of it. --- QuantExt/qle/math/basiccpuenvironment.cpp | 1 - QuantExt/qle/math/cudaenvironment.cpp | 2 +- QuantExt/qle/math/openclenvironment.cpp | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/QuantExt/qle/math/basiccpuenvironment.cpp b/QuantExt/qle/math/basiccpuenvironment.cpp index 42b9aa5e1..6f3922102 100644 --- a/QuantExt/qle/math/basiccpuenvironment.cpp +++ b/QuantExt/qle/math/basiccpuenvironment.cpp @@ -29,7 +29,6 @@ #include #include -#include namespace QuantExt { diff --git a/QuantExt/qle/math/cudaenvironment.cpp b/QuantExt/qle/math/cudaenvironment.cpp index 963e31530..c7e2d58c9 100644 --- a/QuantExt/qle/math/cudaenvironment.cpp +++ b/QuantExt/qle/math/cudaenvironment.cpp @@ -24,13 +24,13 @@ #include #include -#include #include #include #include #ifdef ORE_ENABLE_CUDA +#include #include #include #include diff --git a/QuantExt/qle/math/openclenvironment.cpp b/QuantExt/qle/math/openclenvironment.cpp index 630129150..5a52636c9 100644 --- a/QuantExt/qle/math/openclenvironment.cpp +++ b/QuantExt/qle/math/openclenvironment.cpp @@ -24,7 +24,6 @@ #include #include -#include #include #include @@ -39,6 +38,7 @@ namespace QuantExt { #ifdef ORE_ENABLE_OPENCL +#include namespace { std::string errorText(cl_int err) { switch (err) { From 808bc18447cd1f53dca2ba895bc04bf017c3e898 Mon Sep 17 00:00:00 2001 From: francis Date: Fri, 28 Nov 2025 17:49:03 +0000 Subject: [PATCH 05/18] Tidy up QuantExt's Boost dependencies. Set BOOST_ALL_NO_LIB in cmake/commonSettings.cmake to turn off auto-linking as is done in QuantLib. Use specific Boost targets in target_link_libraries calls in QuantExt and QuantExt test suite. As per QuantLib, no linking to Boost unit_test_framework needed since the header only approach is being used i.e. #define BOOST_TEST_MODULE "QuantExtTestSuite" #include Centralize the find_package call for Boost to cmake/commonSettings.cmake. Fix set_ql_library_name macro when USE_GLOBAL_ORE_BUILD is OFF. --- QuantExt/CMakeLists.txt | 11 ----------- QuantExt/qle/CMakeLists.txt | 2 +- QuantExt/test/CMakeLists.txt | 7 ++++--- cmake/commonSettings.cmake | 8 +++++++- 4 files changed, 12 insertions(+), 16 deletions(-) diff --git a/QuantExt/CMakeLists.txt b/QuantExt/CMakeLists.txt index e0bce3463..469c17f55 100644 --- a/QuantExt/CMakeLists.txt +++ b/QuantExt/CMakeLists.txt @@ -7,16 +7,6 @@ enable_testing() get_library_name("QuantExt" QLE_LIB_NAME) set_ql_library_name() -if (ORE_BUILD_TESTS) - SET(COMPONENTS_CONDITIONAL "unit_test_framework") -else() - SET(COMPONENTS_CONDITIONAL "") -endif() - - -find_package (Boost REQUIRED COMPONENTS ${COMPONENTS_CONDITIONAL} date_time thread serialization timer log_setup log filesystem OPTIONAL_COMPONENTS system chrono) - - if (ORE_ENABLE_PARALLEL_UNIT_TEST_RUNNER AND UNIX AND NOT APPLE) find_library(RT_LIBRARY rt REQUIRED) endif() @@ -52,7 +42,6 @@ if (ORE_PYTHON_INTEGRATION) include_directories(${Python_INCLUDE_DIRS}) endif() -include_directories(${Boost_INCLUDE_DIRS}) include_directories(${QUANTLIB_SOURCE_DIR}) include_directories(${ORETEST_SOURCE_DIR}) include_directories(${CMAKE_CURRENT_SOURCE_DIR}) diff --git a/QuantExt/qle/CMakeLists.txt b/QuantExt/qle/CMakeLists.txt index f747a1ed5..c856c77ce 100644 --- a/QuantExt/qle/CMakeLists.txt +++ b/QuantExt/qle/CMakeLists.txt @@ -1082,7 +1082,7 @@ version.hpp) writeAll("qle" "quantext.hpp" "auto_link.hpp" "${QuantExt_HDR}") add_library(${QLE_LIB_NAME} ${QuantExt_SRC}) -target_link_libraries(${QLE_LIB_NAME} ${QL_LIB_NAME} ${Boost_LIBRARIES}) +target_link_libraries(${QLE_LIB_NAME} ${QL_LIB_NAME} Boost::boost Boost::serialization Boost::timer) if(ORE_ENABLE_OPENCL) if(APPLE) diff --git a/QuantExt/test/CMakeLists.txt b/QuantExt/test/CMakeLists.txt index 98e47c698..7f6f2463a 100644 --- a/QuantExt/test/CMakeLists.txt +++ b/QuantExt/test/CMakeLists.txt @@ -98,9 +98,10 @@ testsuite.cpp transitionmatrix.cpp) add_executable(quantext-test-suite ${QuantExt-Test_SRC}) -target_link_libraries(quantext-test-suite ${QL_LIB_NAME}) -target_link_libraries(quantext-test-suite ${QLE_LIB_NAME}) -target_link_libraries(quantext-test-suite ${Boost_LIBRARIES} ${RT_LIBRARY}) +target_link_libraries(quantext-test-suite ${QL_LIB_NAME} ${QLE_LIB_NAME} Boost::log) +if(DEFINED RT_LIBRARY AND NOT "${RT_LIBRARY}" MATCHES ".*NOTFOUND$") + target_link_libraries(quantext-test-suite ${RT_LIBRARY}) +endif() add_test(NAME quantext-test-suite COMMAND quantext-test-suite WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}) diff --git a/cmake/commonSettings.cmake b/cmake/commonSettings.cmake index b0a2cddcd..45d830965 100644 --- a/cmake/commonSettings.cmake +++ b/cmake/commonSettings.cmake @@ -239,8 +239,13 @@ endif() set(Boost_NO_WARN_NEW_VERSIONS ON) +# Avoid using Boost auto-linking +add_compile_definitions(BOOST_ALL_NO_LIB) + +# Find Boost components. +find_package(Boost REQUIRED COMPONENTS serialization timer log) + if (MSVC) - find_package(Boost) if(Boost_VERSION_STRING LESS 1.84.0) add_compile_definitions(_WINVER=0x0601) add_compile_definitions(_WIN32_WINNT=0x0601) @@ -309,6 +314,7 @@ macro(set_ql_library_name) set(QL_LIB_NAME ql_library) else() get_library_name("QuantLib" QL_LIB_NAME) + set(QL_LIB_NAME "${QL_LIB_NAME}$<$:${CMAKE_DEBUG_POSTFIX}>") endif() endmacro() From 1c6234f7ffbb5f615cfce7d9d9a25b8d2e246f8b Mon Sep 17 00:00:00 2001 From: francis Date: Fri, 28 Nov 2025 20:36:54 +0000 Subject: [PATCH 06/18] Tidy up OREData's Boost dependencies. Use specific Boost targets in target_link_libraries calls in OREData and OREData test suite. No need to use Boost_INCLUDE_DIRS and Boost_LIBRARIES as the usage requirements are passed via the Boost targets. --- OREData/CMakeLists.txt | 10 ---------- OREData/ored/CMakeLists.txt | 5 +---- OREData/test/CMakeLists.txt | 7 +++---- cmake/commonSettings.cmake | 6 +++++- 4 files changed, 9 insertions(+), 19 deletions(-) diff --git a/OREData/CMakeLists.txt b/OREData/CMakeLists.txt index 5d866dea7..4dd7e7008 100644 --- a/OREData/CMakeLists.txt +++ b/OREData/CMakeLists.txt @@ -8,16 +8,6 @@ get_library_name("OREData" ORED_LIB_NAME) get_library_name("QuantExt" QLE_LIB_NAME) set_ql_library_name() -if (ORE_BUILD_TESTS) - SET(COMPONENTS_CONDITIONAL "unit_test_framework") -else() - SET(COMPONENTS_CONDITIONAL "") -endif() - -find_package (Boost REQUIRED COMPONENTS ${COMPONENTS_CONDITIONAL} date_time thread serialization timer log_setup log filesystem OPTIONAL_COMPONENTS system chrono) - - -include_directories(${Boost_INCLUDE_DIRS}) include_directories(${QUANTLIB_SOURCE_DIR}) include_directories(${QUANTEXT_SOURCE_DIR}) include_directories(${ORETEST_SOURCE_DIR}) diff --git a/OREData/ored/CMakeLists.txt b/OREData/ored/CMakeLists.txt index 67c7b7594..3d0dfc048 100644 --- a/OREData/ored/CMakeLists.txt +++ b/OREData/ored/CMakeLists.txt @@ -825,10 +825,7 @@ version.hpp) writeAll("ored" "ored.hpp" "auto_link.hpp" "${OREData_HDR}") add_library(${ORED_LIB_NAME} ${OREData_SRC}) -target_link_libraries(${ORED_LIB_NAME} ${QLE_LIB_NAME}) -target_link_libraries(${ORED_LIB_NAME} ${QL_LIB_NAME}) -target_link_libraries(${ORED_LIB_NAME} ${Boost_LIBRARIES}) - +target_link_libraries(${ORED_LIB_NAME} ${QL_LIB_NAME} ${QLE_LIB_NAME} Boost::filesystem Boost::log) if (QL_USE_PCH) target_precompile_headers(${ORED_LIB_NAME} diff --git a/OREData/test/CMakeLists.txt b/OREData/test/CMakeLists.txt index 3ad25da6a..c9c5811b1 100644 --- a/OREData/test/CMakeLists.txt +++ b/OREData/test/CMakeLists.txt @@ -76,10 +76,9 @@ yieldcurve.cpp zerocouponswap.cpp) add_executable(ored-test-suite ${OREData-Test_SRC}) -target_link_libraries(ored-test-suite ${ORED_LIB_NAME}) -target_link_libraries(ored-test-suite ${QLE_LIB_NAME}) -target_link_libraries(ored-test-suite ${QL_LIB_NAME}) -target_link_libraries(ored-test-suite ${Boost_LIBRARIES}) +target_link_libraries(ored-test-suite ${QL_LIB_NAME} ${QLE_LIB_NAME} ${ORED_LIB_NAME} + Boost::unit_test_framework +) # under windows our unit test code switches to .. since it assumes the test executable is run from /bin # we work around that by explicitly specifying the base_data_path to be the current directory diff --git a/cmake/commonSettings.cmake b/cmake/commonSettings.cmake index 45d830965..3dc2f1b7b 100644 --- a/cmake/commonSettings.cmake +++ b/cmake/commonSettings.cmake @@ -243,7 +243,11 @@ set(Boost_NO_WARN_NEW_VERSIONS ON) add_compile_definitions(BOOST_ALL_NO_LIB) # Find Boost components. -find_package(Boost REQUIRED COMPONENTS serialization timer log) +set(BOOST_COMPONENT_LIST filesystem serialization timer log) +if(ORE_BUILD_TESTS) + list(APPEND BOOST_COMPONENT_LIST unit_test_framework) +endif() +find_package(Boost REQUIRED COMPONENTS ${BOOST_COMPONENT_LIST}) if (MSVC) if(Boost_VERSION_STRING LESS 1.84.0) From 1132882761e016a5a27220105efbecf9cbe106fe Mon Sep 17 00:00:00 2001 From: francis Date: Fri, 28 Nov 2025 21:10:11 +0000 Subject: [PATCH 07/18] Tidy up OREAnalytic's Boost dependencies. Will need an additional change later for the ORE_USE_ZLIB case. --- OREAnalytics/CMakeLists.txt | 18 ------------------ OREAnalytics/orea/CMakeLists.txt | 5 +---- OREAnalytics/test/CMakeLists.txt | 9 ++++----- 3 files changed, 5 insertions(+), 27 deletions(-) diff --git a/OREAnalytics/CMakeLists.txt b/OREAnalytics/CMakeLists.txt index 1dcb0af5a..114de0035 100644 --- a/OREAnalytics/CMakeLists.txt +++ b/OREAnalytics/CMakeLists.txt @@ -9,28 +9,10 @@ get_library_name("OREData" ORED_LIB_NAME) get_library_name("QuantExt" QLE_LIB_NAME) set_ql_library_name() -if(MSVC) - add_compile_definitions(BOOST_IOSTREAMS_NO_LIB) -endif() - if(ORE_USE_ZLIB) find_package(ZLIB REQUIRED) endif() -SET(COMPONENT_LIST date_time filesystem iostreams serialization timer thread) - -if (ORE_BUILD_TESTS) - LIST(APPEND COMPONENT_LIST unit_test_framework) -endif() -if(MSVC AND ORE_USE_ZLIB) - LIST(APPEND COMPONENT_LIST zlib) -endif() -find_package (Boost REQUIRED COMPONENTS ${COMPONENT_LIST} OPTIONAL_COMPONENTS system chrono) -if (ORE_ENABLE_PARALLEL_UNIT_TEST_RUNNER AND UNIX AND NOT APPLE) - find_library(RT_LIBRARY rt REQUIRED) -endif() - -include_directories(${Boost_INCLUDE_DIRS}) include_directories(${QUANTLIB_SOURCE_DIR}) include_directories(${QUANTEXT_SOURCE_DIR}) include_directories(${OREDATA_SOURCE_DIR}) diff --git a/OREAnalytics/orea/CMakeLists.txt b/OREAnalytics/orea/CMakeLists.txt index 2ed5bc917..217909044 100644 --- a/OREAnalytics/orea/CMakeLists.txt +++ b/OREAnalytics/orea/CMakeLists.txt @@ -443,10 +443,7 @@ version.hpp) writeAll("orea" "orea.hpp" "auto_link.hpp" "${OREAnalytics_HDR}") add_library(${OREA_LIB_NAME} ${OREAnalytics_SRC}) -target_link_libraries(${OREA_LIB_NAME} ${QL_LIB_NAME}) -target_link_libraries(${OREA_LIB_NAME} ${QLE_LIB_NAME}) -target_link_libraries(${OREA_LIB_NAME} ${ORED_LIB_NAME}) -target_link_libraries(${OREA_LIB_NAME} ${Boost_LIBRARIES}) +target_link_libraries(${OREA_LIB_NAME} ${QL_LIB_NAME} ${QLE_LIB_NAME} ${ORED_LIB_NAME}) if(ORE_USE_ZLIB) target_link_libraries(${OREA_LIB_NAME} ${ZLIB_LIBRARIES}) diff --git a/OREAnalytics/test/CMakeLists.txt b/OREAnalytics/test/CMakeLists.txt index ad11f4117..4ec498fb8 100644 --- a/OREAnalytics/test/CMakeLists.txt +++ b/OREAnalytics/test/CMakeLists.txt @@ -29,11 +29,10 @@ testportfolio.cpp testsuite.cpp) add_executable(orea-test-suite ${OREAnalytics-Test_SRC}) -target_link_libraries(orea-test-suite ${QL_LIB_NAME}) -target_link_libraries(orea-test-suite ${QLE_LIB_NAME}) -target_link_libraries(orea-test-suite ${ORED_LIB_NAME}) -target_link_libraries(orea-test-suite ${OREA_LIB_NAME}) -target_link_libraries(orea-test-suite ${Boost_LIBRARIES} ${RT_LIBRARY}) +target_link_libraries(orea-test-suite ${QL_LIB_NAME} ${QLE_LIB_NAME} ${ORED_LIB_NAME} ${OREA_LIB_NAME}) +if(DEFINED RT_LIBRARY AND NOT "${RT_LIBRARY}" MATCHES ".*NOTFOUND$") + target_link_libraries(orea-test-suite ${RT_LIBRARY}) +endif() add_test(NAME orea-test-suite WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR} COMMAND orea-test-suite -- --base_data_path=.) From f9941ca21b5ef326c2cbeb7ea51188ee34fa8298 Mon Sep 17 00:00:00 2001 From: francis Date: Fri, 28 Nov 2025 21:18:26 +0000 Subject: [PATCH 08/18] Tidy up OREApp's Boost dependencies. --- App/CMakeLists.txt | 5 ----- 1 file changed, 5 deletions(-) diff --git a/App/CMakeLists.txt b/App/CMakeLists.txt index 7707bed03..7c9c09b72 100644 --- a/App/CMakeLists.txt +++ b/App/CMakeLists.txt @@ -8,9 +8,6 @@ get_library_name("OREData" ORED_LIB_NAME) get_library_name("QuantExt" QLE_LIB_NAME) set_ql_library_name() -find_package (Boost REQUIRED COMPONENTS date_time serialization filesystem timer OPTIONAL_COMPONENTS chrono) - -include_directories(${Boost_INCLUDE_DIRS}) include_directories(${QUANTLIB_SOURCE_DIR}) include_directories(${QUANTEXT_SOURCE_DIR}) include_directories(${OREDATA_SOURCE_DIR}) @@ -21,7 +18,6 @@ add_link_directory_if_exists("${QUANTLIB_SOURCE_DIR}/build/ql") add_link_directory_if_exists("${QUANTEXT_SOURCE_DIR}/build/qle") add_link_directory_if_exists("${OREDATA_SOURCE_DIR}/build/ored") add_link_directory_if_exists("${OREANALYTICS_SOURCE_DIR}/build/orea") - add_link_directory_if_exists("${CMAKE_BINARY_DIR}/QuantLib/ql") add_executable(ore ore.cpp) @@ -29,7 +25,6 @@ target_link_libraries(ore ${OREA_LIB_NAME}) target_link_libraries(ore ${ORED_LIB_NAME}) target_link_libraries(ore ${QLE_LIB_NAME}) target_link_libraries(ore ${QL_LIB_NAME}) -target_link_libraries(ore ${Boost_LIBRARIES}) if (ORE_PYTHON_INTEGRATION) target_link_libraries(ore ${Python_LIBRARIES}) endif() From 4929e59a0453a246ed00b90a6783a11635581659 Mon Sep 17 00:00:00 2001 From: francis Date: Fri, 28 Nov 2025 21:43:24 +0000 Subject: [PATCH 09/18] Tidy up ORE-SWIG's Boost dependencies. --- ORE-SWIG/CMakeLists.txt | 21 +++++++------------ .../OREAnalytics-SWIG/Java/CMakeLists.txt | 5 +---- ORE-SWIG/OREData-SWIG/Java/CmakeLists.txt | 6 +----- 3 files changed, 10 insertions(+), 22 deletions(-) diff --git a/ORE-SWIG/CMakeLists.txt b/ORE-SWIG/CMakeLists.txt index f909fbcf4..8080a70e0 100644 --- a/ORE-SWIG/CMakeLists.txt +++ b/ORE-SWIG/CMakeLists.txt @@ -31,17 +31,12 @@ get_library_name("OREData" ORED_LIB_NAME) get_library_name("QuantExt" QLE_LIB_NAME) set_ql_library_name() -# To build the module, we moreover need Boost, Swig, Python -set(BOOST_COMPONENT_LIST serialization date_time filesystem timer thread log regex) - - -if(ORE_USE_ZLIB) - list(APPEND BOOST_COMPONENT_LIST iostreams) - if(MSVC) - list(APPEND BOOST_COMPONENT_LIST zlib) - endif() -endif() -find_package(Boost REQUIRED COMPONENTS ${BOOST_COMPONENT_LIST} OPTIONAL_COMPONENTS system) +# FD-BST: if(ORE_USE_ZLIB) +# FD-BST: list(APPEND BOOST_COMPONENT_LIST iostreams) +# FD-BST: if(MSVC) +# FD-BST: list(APPEND BOOST_COMPONENT_LIST zlib) +# FD-BST: endif() +# FD-BST: endif() find_package(SWIG REQUIRED) find_package(Python REQUIRED COMPONENTS Development) if(ORE_USE_ZLIB) @@ -64,7 +59,7 @@ include_directories(${QUANTEXT_SOURCE_DIR}) include_directories(${OREDATA_SOURCE_DIR}) include_directories(${OREANALYTICS_SOURCE_DIR}) -include_directories(${Boost_INCLUDE_DIRS}) +# FD-BST: include_directories(${Boost_INCLUDE_DIRS}) include_directories(${Python_INCLUDE_DIRS}) # Add to the list of link directories @@ -107,7 +102,7 @@ swig_add_library(OREP TYPE MODULE LANGUAGE python SOURCES ${PROJECT_SOURCE_DIR}/ set(CMAKE_DEBUG_POSTFIX ${TEMP_CMAKE_DEBUG_POSTFIX}) # Add all libraries to link with -target_link_libraries(OREP ${Boost_LIBRARIES}) +target_link_libraries(OREP Boost::boost Boost::filesystem Boost::log Boost::serialization Boost::timer) target_link_libraries(OREP ${QL_LIB_NAME}) target_link_libraries(OREP ${QLE_LIB_NAME}) target_link_libraries(OREP ${ORED_LIB_NAME}) diff --git a/ORE-SWIG/OREAnalytics-SWIG/Java/CMakeLists.txt b/ORE-SWIG/OREAnalytics-SWIG/Java/CMakeLists.txt index 5c4476312..f588f0f5f 100755 --- a/ORE-SWIG/OREAnalytics-SWIG/Java/CMakeLists.txt +++ b/ORE-SWIG/OREAnalytics-SWIG/Java/CMakeLists.txt @@ -51,9 +51,6 @@ include_directories(${PROJECT_SOURCE_DIR}/../../QuantExt-SWIG/SWIG) include_directories(${PROJECT_SOURCE_DIR}/../../OREData-SWIG/SWIG) include_directories(${PROJECT_SOURCE_DIR}/../../OREAnalytics-SWIG/SWIG) -find_package (Boost REQUIRED COMPONENTS serialization date_time filesystem OPTIONAL_COMPONENTS system) -include_directories(${Boost_INCLUDE_DIRS}) - # specify library search path (update this when we build ORE with cmake) add_link_directory_if_exists(${ORE}/build/QuantLib/ql) add_link_directory_if_exists(${ORE}/build/QuantExt/qle) @@ -84,7 +81,7 @@ swig_link_libraries(${ORE_JAVA_LIB_NAME} ${QL_LIB_NAME}) swig_link_libraries(${ORE_JAVA_LIB_NAME} ${QLE_LIB_NAME}) swig_link_libraries(${ORE_JAVA_LIB_NAME} ${ORED_LIB_NAME}) swig_link_libraries(${ORE_JAVA_LIB_NAME} ${OREA_LIB_NAME}) -swig_link_libraries(${ORE_JAVA_LIB_NAME} ${Boost_LIBRARIES}) +swig_link_libraries(${ORE_JAVA_LIB_NAME} Boost::boost Boost::filesystem Boost::log Boost::serialization Boost::timer) #add_dependencies(${ORE_JAVA_LIB_NAME} ${QLE_LIB_NAME}) #add_dependencies(${ORE_JAVA_LIB_NAME} ${ORED_LIB_NAME}) diff --git a/ORE-SWIG/OREData-SWIG/Java/CmakeLists.txt b/ORE-SWIG/OREData-SWIG/Java/CmakeLists.txt index 6a2df852c..0d9b1ee2f 100644 --- a/ORE-SWIG/OREData-SWIG/Java/CmakeLists.txt +++ b/ORE-SWIG/OREData-SWIG/Java/CmakeLists.txt @@ -48,10 +48,6 @@ include_directories(${PROJECT_SOURCE_DIR}/../../QuantLib-SWIG/SWIG) include_directories(${PROJECT_SOURCE_DIR}/../../QuantExt-SWIG/SWIG) include_directories(${PROJECT_SOURCE_DIR}/../../OREData-SWIG/SWIG) -find_package (Boost REQUIRED COMPONENTS serialization date_time regex filesystem OPTIONAL_COMPONENTS system) - -include_directories(${Boost_INCLUDE_DIRS}) - # specify library search path (update this when we build ORE with cmake) link_directories(${ORE}/build/QuantLib/ql) link_directories(${ORE}/build/QuantExt/qle) @@ -80,7 +76,7 @@ swig_add_library(${ORE_JAVA_LIB_NAME} TYPE SHARED LANGUAGE java SOURCES ${PROJEC swig_link_libraries(${ORE_JAVA_LIB_NAME} ${QL_LIB_NAME}) swig_link_libraries(${ORE_JAVA_LIB_NAME} ${QLE_LIB_NAME}) swig_link_libraries(${ORE_JAVA_LIB_NAME} ${ORED_LIB_NAME}) -swig_link_libraries(${ORE_JAVA_LIB_NAME} ${Boost_LIBRARIES}) +swig_link_libraries(${ORE_JAVA_LIB_NAME} Boost::boost Boost::filesystem Boost::log Boost::serialization Boost::timer) #add_dependencies(${ORE_JAVA_LIB_NAME} ${QLE_LIB_NAME}) #add_dependencies(${ORE_JAVA_LIB_NAME} ${ORED_LIB_NAME}) From 1b576939833aea8e9684b597844e64e0d6085915 Mon Sep 17 00:00:00 2001 From: francis Date: Fri, 28 Nov 2025 23:22:54 +0000 Subject: [PATCH 10/18] Allow SWIG build when USE_GLOBAL_ORE_BUILD is OFF. --- ORE-SWIG/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/ORE-SWIG/CMakeLists.txt b/ORE-SWIG/CMakeLists.txt index 8080a70e0..ccd3e2e42 100644 --- a/ORE-SWIG/CMakeLists.txt +++ b/ORE-SWIG/CMakeLists.txt @@ -70,6 +70,7 @@ add_link_directory_if_exists("${OREDATA_SOURCE_DIR}/build/ored") add_link_directory_if_exists("${OREANALYTICS_SOURCE_DIR}/build/orea") add_link_directory_if_exists("${CMAKE_BINARY_DIR}/QuantLib") +add_link_directory_if_exists("${CMAKE_BINARY_DIR}/QuantLib/ql") add_link_directory_if_exists("${CMAKE_BINARY_DIR}/ore/QuantLib") if(EXISTS "${CMAKE_BINARY_DIR}/ore/QuantLib/") From 56c0d3353a2a1577157483ec48447b52c7bb239e Mon Sep 17 00:00:00 2001 From: francis Date: Sat, 29 Nov 2025 14:46:50 +0000 Subject: [PATCH 11/18] Update Boost handling for ORE_USE_ZLIB true. --- ORE-SWIG/CMakeLists.txt | 16 ++++------------ OREAnalytics/orea/CMakeLists.txt | 5 ++++- cmake/commonSettings.cmake | 6 ++++++ 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/ORE-SWIG/CMakeLists.txt b/ORE-SWIG/CMakeLists.txt index ccd3e2e42..c33e80051 100644 --- a/ORE-SWIG/CMakeLists.txt +++ b/ORE-SWIG/CMakeLists.txt @@ -31,12 +31,6 @@ get_library_name("OREData" ORED_LIB_NAME) get_library_name("QuantExt" QLE_LIB_NAME) set_ql_library_name() -# FD-BST: if(ORE_USE_ZLIB) -# FD-BST: list(APPEND BOOST_COMPONENT_LIST iostreams) -# FD-BST: if(MSVC) -# FD-BST: list(APPEND BOOST_COMPONENT_LIST zlib) -# FD-BST: endif() -# FD-BST: endif() find_package(SWIG REQUIRED) find_package(Python REQUIRED COMPONENTS Development) if(ORE_USE_ZLIB) @@ -51,15 +45,10 @@ include_directories(${PROJECT_SOURCE_DIR}/OREAnalytics-SWIG/SWIG) include_directories(${PROJECT_SOURCE_DIR}/QuantLib-SWIG/SWIG) include_directories(${PROJECT_SOURCE_DIR}/QuantExt-SWIG/SWIG) include_directories(${PROJECT_SOURCE_DIR}/OREData-SWIG/SWIG) - -#include_directories(${ORE_BUILD}/QuantLib) - include_directories(${QUANTLIB_SOURCE_DIR}) include_directories(${QUANTEXT_SOURCE_DIR}) include_directories(${OREDATA_SOURCE_DIR}) include_directories(${OREANALYTICS_SOURCE_DIR}) - -# FD-BST: include_directories(${Boost_INCLUDE_DIRS}) include_directories(${Python_INCLUDE_DIRS}) # Add to the list of link directories @@ -109,7 +98,10 @@ target_link_libraries(OREP ${QLE_LIB_NAME}) target_link_libraries(OREP ${ORED_LIB_NAME}) target_link_libraries(OREP ${OREA_LIB_NAME}) if(ORE_USE_ZLIB) - target_link_libraries(OREP ${ZLIB_LIBRARIES}) + target_link_libraries(OREP ${ZLIB_LIBRARIES} Boost::iostreams) + if(MSVC) + target_link_libraries(OREP Boost::zlib) + endif() endif() # On windows, do not tell the build which python libs to use. It automatically # looks for python release libs, even in debug, and invoking the line below diff --git a/OREAnalytics/orea/CMakeLists.txt b/OREAnalytics/orea/CMakeLists.txt index 217909044..63765c477 100644 --- a/OREAnalytics/orea/CMakeLists.txt +++ b/OREAnalytics/orea/CMakeLists.txt @@ -446,7 +446,10 @@ add_library(${OREA_LIB_NAME} ${OREAnalytics_SRC}) target_link_libraries(${OREA_LIB_NAME} ${QL_LIB_NAME} ${QLE_LIB_NAME} ${ORED_LIB_NAME}) if(ORE_USE_ZLIB) - target_link_libraries(${OREA_LIB_NAME} ${ZLIB_LIBRARIES}) + target_link_libraries(${OREA_LIB_NAME} ${ZLIB_LIBRARIES} Boost::iostreams) + if(MSVC) + target_link_libraries(${OREA_LIB_NAME} Boost::zlib) + endif() endif() if (QL_USE_PCH) diff --git a/cmake/commonSettings.cmake b/cmake/commonSettings.cmake index 3dc2f1b7b..f47a2b186 100644 --- a/cmake/commonSettings.cmake +++ b/cmake/commonSettings.cmake @@ -247,6 +247,12 @@ set(BOOST_COMPONENT_LIST filesystem serialization timer log) if(ORE_BUILD_TESTS) list(APPEND BOOST_COMPONENT_LIST unit_test_framework) endif() +if(ORE_USE_ZLIB) + list(APPEND BOOST_COMPONENT_LIST iostreams) + if(MSVC) + list(APPEND BOOST_COMPONENT_LIST zlib) + endif() +endif() find_package(Boost REQUIRED COMPONENTS ${BOOST_COMPONENT_LIST}) if (MSVC) From beb08067a573ea015966f0e52d4aaeab873d8e7e Mon Sep 17 00:00:00 2001 From: francis Date: Sat, 29 Nov 2025 15:13:56 +0000 Subject: [PATCH 12/18] Remove explicit dependence on Boost::zlib. With just Boost::iostreams target, Boost::zlib and Boost::bzip2 are pulled in as well. --- ORE-SWIG/CMakeLists.txt | 3 --- OREAnalytics/orea/CMakeLists.txt | 3 --- cmake/commonSettings.cmake | 3 --- 3 files changed, 9 deletions(-) diff --git a/ORE-SWIG/CMakeLists.txt b/ORE-SWIG/CMakeLists.txt index c33e80051..34fc61182 100644 --- a/ORE-SWIG/CMakeLists.txt +++ b/ORE-SWIG/CMakeLists.txt @@ -99,9 +99,6 @@ target_link_libraries(OREP ${ORED_LIB_NAME}) target_link_libraries(OREP ${OREA_LIB_NAME}) if(ORE_USE_ZLIB) target_link_libraries(OREP ${ZLIB_LIBRARIES} Boost::iostreams) - if(MSVC) - target_link_libraries(OREP Boost::zlib) - endif() endif() # On windows, do not tell the build which python libs to use. It automatically # looks for python release libs, even in debug, and invoking the line below diff --git a/OREAnalytics/orea/CMakeLists.txt b/OREAnalytics/orea/CMakeLists.txt index 63765c477..b25c7dba5 100644 --- a/OREAnalytics/orea/CMakeLists.txt +++ b/OREAnalytics/orea/CMakeLists.txt @@ -447,9 +447,6 @@ target_link_libraries(${OREA_LIB_NAME} ${QL_LIB_NAME} ${QLE_LIB_NAME} ${ORED_LIB if(ORE_USE_ZLIB) target_link_libraries(${OREA_LIB_NAME} ${ZLIB_LIBRARIES} Boost::iostreams) - if(MSVC) - target_link_libraries(${OREA_LIB_NAME} Boost::zlib) - endif() endif() if (QL_USE_PCH) diff --git a/cmake/commonSettings.cmake b/cmake/commonSettings.cmake index f47a2b186..9a0e6f69d 100644 --- a/cmake/commonSettings.cmake +++ b/cmake/commonSettings.cmake @@ -249,9 +249,6 @@ if(ORE_BUILD_TESTS) endif() if(ORE_USE_ZLIB) list(APPEND BOOST_COMPONENT_LIST iostreams) - if(MSVC) - list(APPEND BOOST_COMPONENT_LIST zlib) - endif() endif() find_package(Boost REQUIRED COMPONENTS ${BOOST_COMPONENT_LIST}) From 27cd1b6c00e4a55ae1f2f97ad592ad0d9f2b09a3 Mon Sep 17 00:00:00 2001 From: francis Date: Sat, 29 Nov 2025 15:59:52 +0000 Subject: [PATCH 13/18] Put find_package(ZLIB in one place. Also use the imported target ZLIB::ZLIB rather than ZLIB_LIBRARIES. --- ORE-SWIG/CMakeLists.txt | 6 +----- OREAnalytics/CMakeLists.txt | 4 ---- OREAnalytics/orea/CMakeLists.txt | 2 +- cmake/commonSettings.cmake | 1 + 4 files changed, 3 insertions(+), 10 deletions(-) diff --git a/ORE-SWIG/CMakeLists.txt b/ORE-SWIG/CMakeLists.txt index 34fc61182..b1e5c6990 100644 --- a/ORE-SWIG/CMakeLists.txt +++ b/ORE-SWIG/CMakeLists.txt @@ -7,7 +7,6 @@ cmake_policy(SET CMP0086 NEW) project(ORE-SWIG) set(CMAKE_SWIG_FLAGS "-fastdispatch") -option(ORE_USE_ZLIB "Use compression for boost::iostreams" OFF) include(${PROJECT_SOURCE_DIR}/../cmake/commonSettings.cmake) @@ -33,9 +32,6 @@ set_ql_library_name() find_package(SWIG REQUIRED) find_package(Python REQUIRED COMPONENTS Development) -if(ORE_USE_ZLIB) - find_package(ZLIB REQUIRED) -endif() # Load the UseSWIG module from the cmake installation include(${SWIG_USE_FILE}) @@ -98,7 +94,7 @@ target_link_libraries(OREP ${QLE_LIB_NAME}) target_link_libraries(OREP ${ORED_LIB_NAME}) target_link_libraries(OREP ${OREA_LIB_NAME}) if(ORE_USE_ZLIB) - target_link_libraries(OREP ${ZLIB_LIBRARIES} Boost::iostreams) + target_link_libraries(OREP ZLIB::ZLIB Boost::iostreams) endif() # On windows, do not tell the build which python libs to use. It automatically # looks for python release libs, even in debug, and invoking the line below diff --git a/OREAnalytics/CMakeLists.txt b/OREAnalytics/CMakeLists.txt index 114de0035..e192d501f 100644 --- a/OREAnalytics/CMakeLists.txt +++ b/OREAnalytics/CMakeLists.txt @@ -9,10 +9,6 @@ get_library_name("OREData" ORED_LIB_NAME) get_library_name("QuantExt" QLE_LIB_NAME) set_ql_library_name() -if(ORE_USE_ZLIB) - find_package(ZLIB REQUIRED) -endif() - include_directories(${QUANTLIB_SOURCE_DIR}) include_directories(${QUANTEXT_SOURCE_DIR}) include_directories(${OREDATA_SOURCE_DIR}) diff --git a/OREAnalytics/orea/CMakeLists.txt b/OREAnalytics/orea/CMakeLists.txt index b25c7dba5..2b1d1f2da 100644 --- a/OREAnalytics/orea/CMakeLists.txt +++ b/OREAnalytics/orea/CMakeLists.txt @@ -446,7 +446,7 @@ add_library(${OREA_LIB_NAME} ${OREAnalytics_SRC}) target_link_libraries(${OREA_LIB_NAME} ${QL_LIB_NAME} ${QLE_LIB_NAME} ${ORED_LIB_NAME}) if(ORE_USE_ZLIB) - target_link_libraries(${OREA_LIB_NAME} ${ZLIB_LIBRARIES} Boost::iostreams) + target_link_libraries(${OREA_LIB_NAME} ZLIB::ZLIB Boost::iostreams) endif() if (QL_USE_PCH) diff --git a/cmake/commonSettings.cmake b/cmake/commonSettings.cmake index 9a0e6f69d..aaaa1bc96 100644 --- a/cmake/commonSettings.cmake +++ b/cmake/commonSettings.cmake @@ -71,6 +71,7 @@ endif() # set compiler macro if zlib is enabled if(ORE_USE_ZLIB) + find_package(ZLIB REQUIRED) add_compile_definitions(ORE_USE_ZLIB) endif() From 3a2d0fa02069f4a297ea63d23ee9bb6c93933436 Mon Sep 17 00:00:00 2001 From: francis Date: Sat, 29 Nov 2025 17:30:42 +0000 Subject: [PATCH 14/18] Refactor the Doxygen doc generation. Refactor by adding function to avoid duplication. --- OREAnalytics/CMakeLists.txt | 2 +- OREAnalytics/doc/CMakeLists.txt | 24 +----------------------- OREData/CMakeLists.txt | 2 +- OREData/doc/CMakeLists.txt | 24 +----------------------- QuantExt/CMakeLists.txt | 2 +- QuantExt/doc/CMakeLists.txt | 24 +----------------------- cmake/commonSettings.cmake | 19 +++++++++++++++++++ 7 files changed, 25 insertions(+), 72 deletions(-) diff --git a/OREAnalytics/CMakeLists.txt b/OREAnalytics/CMakeLists.txt index e192d501f..86be3f895 100644 --- a/OREAnalytics/CMakeLists.txt +++ b/OREAnalytics/CMakeLists.txt @@ -24,7 +24,7 @@ add_link_directory_if_exists("${CMAKE_BINARY_DIR}/QuantExt/qle") add_link_directory_if_exists("${CMAKE_BINARY_DIR}/OREData/ored") add_subdirectory("orea") -if (ORE_BUILD_DOC) +if (ORE_BUILD_DOC AND Doxygen_FOUND) add_subdirectory("doc") endif() if (ORE_BUILD_TESTS) diff --git a/OREAnalytics/doc/CMakeLists.txt b/OREAnalytics/doc/CMakeLists.txt index ce3a3f406..14f4b50b7 100644 --- a/OREAnalytics/doc/CMakeLists.txt +++ b/OREAnalytics/doc/CMakeLists.txt @@ -1,23 +1 @@ -# first we can indicate the documentation build as an option and set it to ON by default -#option(ORE_BUILD_DOC "Build documentation" ON) - -# check if Doxygen is installed -find_package(Doxygen) -if (DOXYGEN_FOUND AND ORE_BUILD_DOC) - # set input and output files - set(DOXYGEN_IN ${CMAKE_CURRENT_SOURCE_DIR}/orea.doxy) - set(DOXYGEN_OUT ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile) - - # request to configure the file - configure_file(${DOXYGEN_IN} ${DOXYGEN_OUT} @ONLY) - message("Doxygen build started") - - # note the option ALL which allows to build the docs together with the application - add_custom_target( doc_orea ALL - COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYGEN_OUT} - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - COMMENT "Generating API documentation with Doxygen" - VERBATIM ) -else (DOXYGEN_FOUND AND ORE_BUILD_DOC) - message("Doxygen need to be installed to generate the doxygen documentation") -endif (DOXYGEN_FOUND AND ORE_BUILD_DOC) +generate_doxy_docs("orea") diff --git a/OREData/CMakeLists.txt b/OREData/CMakeLists.txt index 4dd7e7008..803d010a9 100644 --- a/OREData/CMakeLists.txt +++ b/OREData/CMakeLists.txt @@ -20,7 +20,7 @@ add_link_directory_if_exists("${CMAKE_BINARY_DIR}/QuantLib/ql") add_link_directory_if_exists("${CMAKE_BINARY_DIR}/QuantExt/qle") add_subdirectory("ored") -if (ORE_BUILD_DOC) +if (ORE_BUILD_DOC AND Doxygen_FOUND) add_subdirectory("doc") endif() if (ORE_BUILD_TESTS) diff --git a/OREData/doc/CMakeLists.txt b/OREData/doc/CMakeLists.txt index 17713b76a..2598692f2 100644 --- a/OREData/doc/CMakeLists.txt +++ b/OREData/doc/CMakeLists.txt @@ -1,23 +1 @@ -# first we can indicate the documentation build as an option and set it to ON by default -# option(ORE_BUILD_DOC "Build documentation" ON) - -# check if Doxygen is installed -find_package(Doxygen) -if (DOXYGEN_FOUND AND ORE_BUILD_DOC) - # set input and output files - set(DOXYGEN_IN ${CMAKE_CURRENT_SOURCE_DIR}/ored.doxy) - set(DOXYGEN_OUT ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile) - - # request to configure the file - configure_file(${DOXYGEN_IN} ${DOXYGEN_OUT} @ONLY) - message("Doxygen build started") - - # note the option ALL which allows to build the docs together with the application - add_custom_target( doc_ored ALL - COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYGEN_OUT} - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - COMMENT "Generating API documentation with Doxygen" - VERBATIM ) -else (DOXYGEN_FOUND AND ORE_BUILD_DOC) - message("Doxygen need to be installed to generate the doxygen documentation") -endif (DOXYGEN_FOUND AND ORE_BUILD_DOC) +generate_doxy_docs("ored") diff --git a/QuantExt/CMakeLists.txt b/QuantExt/CMakeLists.txt index 469c17f55..099d3a745 100644 --- a/QuantExt/CMakeLists.txt +++ b/QuantExt/CMakeLists.txt @@ -52,7 +52,7 @@ add_link_directory_if_exists("${CMAKE_BINARY_DIR}/QuantLib/ql") generate_git_hash(ore_qle) add_subdirectory("qle") -if (ORE_BUILD_DOC) +if (ORE_BUILD_DOC AND Doxygen_FOUND) add_subdirectory("doc") endif() if (ORE_BUILD_TESTS) diff --git a/QuantExt/doc/CMakeLists.txt b/QuantExt/doc/CMakeLists.txt index 4226a6d6c..f95707713 100644 --- a/QuantExt/doc/CMakeLists.txt +++ b/QuantExt/doc/CMakeLists.txt @@ -1,23 +1 @@ -# first we can indicate the documentation build as an option and set it to ON by default -# option(ORE_BUILD_DOC "Build documentation" ON) - -# check if Doxygen is installed -find_package(Doxygen) -if (DOXYGEN_FOUND AND ORE_BUILD_DOC) - # set input and output files - set(DOXYGEN_IN ${CMAKE_CURRENT_SOURCE_DIR}/quantext.doxy) - set(DOXYGEN_OUT ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile) - - # request to configure the file - configure_file(${DOXYGEN_IN} ${DOXYGEN_OUT} @ONLY) - message("Doxygen build started") - - # note the option ALL which allows to build the docs together with the application - add_custom_target( doc_quantext ALL - COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYGEN_OUT} - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - COMMENT "Generating API documentation with Doxygen" - VERBATIM ) -else (DOXYGEN_FOUND AND ORE_BUILD_DOC) - message("Doxygen need to be installed to generate the doxygen documentation") -endif (DOXYGEN_FOUND AND ORE_BUILD_DOC) +generate_doxy_docs("quantext") diff --git a/cmake/commonSettings.cmake b/cmake/commonSettings.cmake index aaaa1bc96..33364918e 100644 --- a/cmake/commonSettings.cmake +++ b/cmake/commonSettings.cmake @@ -334,3 +334,22 @@ function(generate_git_hash custom_target_name) -P ${QUANTEXT_SOURCE_DIR}/../cmake/generateGitVersion.cmake WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}) endfunction() + +find_package(Doxygen) +if(ORE_BUILD_DOC AND NOT Doxygen_FOUND) + message("Doxygen needs to be installed to generate the doxygen documentation.") +endif() + +function(generate_doxy_docs doxy_filename) + # Set the Doxygen input and output files. + set(DOXYGEN_IN ${CMAKE_CURRENT_SOURCE_DIR}/${doxy_filename}.doxy) + set(DOXYGEN_OUT ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile) + configure_file(${DOXYGEN_IN} ${DOXYGEN_OUT} @ONLY) + + add_custom_target("doc_${doxy_filename}" ALL + COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYGEN_OUT} + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + COMMENT "Generating API documentation for ${doxy_filename} with Doxygen." + VERBATIM + ) +endfunction() From c50820fe7459fd0ce63e783fae5a3df615acc537 Mon Sep 17 00:00:00 2001 From: francis Date: Sat, 29 Nov 2025 18:41:43 +0000 Subject: [PATCH 15/18] Include guard for commonSettings.cmake. Prevent commonSettings.cmake getting included more than once. It was getting included by CMakeLists.txt and ORE-SWIG/CMakeLists.txt. --- cmake/commonSettings.cmake | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cmake/commonSettings.cmake b/cmake/commonSettings.cmake index 33364918e..ded4c9b35 100644 --- a/cmake/commonSettings.cmake +++ b/cmake/commonSettings.cmake @@ -1,3 +1,5 @@ +include_guard(GLOBAL) + include(CheckCXXCompilerFlag) include(CheckLinkerFlag) From 314b2b2d7a94334a24498da127516be1502d27d8 Mon Sep 17 00:00:00 2001 From: francis Date: Sun, 30 Nov 2025 12:13:27 +0000 Subject: [PATCH 16/18] Prevent gcc error when -Werror=return-type. This is done a couple of other places: OREData/ored/portfolio/builders/yoycapfloor.cpp OREData/ored/portfolio/builders/capfloor.cpp My gcc compiler version: gcc (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0 If you preprocess the file first and then remove the do {...} while(false); surrounding the code, the compilation works even with the break; statement. Everywhere in QuantLib that we have a non-void function with returns inside switch case blocks, the default case has QL_FAIL not followed by a break;. I guess it is for this reason. --- OREData/ored/portfolio/builders/deltagammaengines.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/OREData/ored/portfolio/builders/deltagammaengines.cpp b/OREData/ored/portfolio/builders/deltagammaengines.cpp index a6edeef50..168c4ebe2 100644 --- a/OREData/ored/portfolio/builders/deltagammaengines.cpp +++ b/OREData/ored/portfolio/builders/deltagammaengines.cpp @@ -55,7 +55,6 @@ EuropeanSwaptionEngineBuilderDeltaGamma::engineImpl(const string& id, const stri computeDeltaVega, computeGamma); default: QL_FAIL("Swaption volatility type " << svts->volatilityType() << "not covered in EngineFactory"); - break; } } From 9b672096f5120a3a054e34dd0b802871a1295a91 Mon Sep 17 00:00:00 2001 From: francis Date: Sun, 30 Nov 2025 16:27:19 +0000 Subject: [PATCH 17/18] Correct order Boost::iostreams -> zlib. The order matters as Boost::iostreams depends on zlib. --- ORE-SWIG/CMakeLists.txt | 2 +- OREAnalytics/orea/CMakeLists.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ORE-SWIG/CMakeLists.txt b/ORE-SWIG/CMakeLists.txt index b1e5c6990..34a1ad857 100644 --- a/ORE-SWIG/CMakeLists.txt +++ b/ORE-SWIG/CMakeLists.txt @@ -94,7 +94,7 @@ target_link_libraries(OREP ${QLE_LIB_NAME}) target_link_libraries(OREP ${ORED_LIB_NAME}) target_link_libraries(OREP ${OREA_LIB_NAME}) if(ORE_USE_ZLIB) - target_link_libraries(OREP ZLIB::ZLIB Boost::iostreams) + target_link_libraries(OREP Boost::iostreams ZLIB::ZLIB) endif() # On windows, do not tell the build which python libs to use. It automatically # looks for python release libs, even in debug, and invoking the line below diff --git a/OREAnalytics/orea/CMakeLists.txt b/OREAnalytics/orea/CMakeLists.txt index 2b1d1f2da..be93c03ca 100644 --- a/OREAnalytics/orea/CMakeLists.txt +++ b/OREAnalytics/orea/CMakeLists.txt @@ -446,7 +446,7 @@ add_library(${OREA_LIB_NAME} ${OREAnalytics_SRC}) target_link_libraries(${OREA_LIB_NAME} ${QL_LIB_NAME} ${QLE_LIB_NAME} ${ORED_LIB_NAME}) if(ORE_USE_ZLIB) - target_link_libraries(${OREA_LIB_NAME} ZLIB::ZLIB Boost::iostreams) + target_link_libraries(${OREA_LIB_NAME} Boost::iostreams ZLIB::ZLIB) endif() if (QL_USE_PCH) From ef207294326e66b4483d71d45ab9339b7cee6a67 Mon Sep 17 00:00:00 2001 From: francis Date: Mon, 1 Dec 2025 16:03:04 +0000 Subject: [PATCH 18/18] Remove duplicate. --- cmake/commonSettings.cmake | 1 - 1 file changed, 1 deletion(-) diff --git a/cmake/commonSettings.cmake b/cmake/commonSettings.cmake index ded4c9b35..b0160b1e3 100644 --- a/cmake/commonSettings.cmake +++ b/cmake/commonSettings.cmake @@ -276,7 +276,6 @@ get_filename_component(ORETEST_SOURCE_DIR "${CMAKE_CURRENT_LIST_DIR}/../ORETest" get_filename_component(RAPIDXML_SOURCE_DIR "${CMAKE_CURRENT_LIST_DIR}/../ThirdPartyLibs/rapidxml-1.13" ABSOLUTE) # parallel unit test runner -option(ORE_ENABLE_PARALLEL_UNIT_TEST_RUNNER "Enable the parallel unit test runner" OFF) if (ORE_ENABLE_PARALLEL_UNIT_TEST_RUNNER) add_definitions(-DORE_ENABLE_PARALLEL_UNIT_TEST_RUNNER) endif()