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 9b4696c859..64b461df37 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 377c810004..f909fbcf45 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 acfb5aa807..5d866dea7a 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 78253c3e16..e0bce34636 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 9a481eee39..fbf73f3758 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 c805d8c256..a6890e2c71 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 c47d170b4c..111c624064 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 ed4136a577..8fd3c397d2 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 227f3e8a76..55778c57be 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 aeb58390a6..9fe56c095a 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 1acb32e5bd..2201144dd5 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 f3d2659d81..3bd52b80ab 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 c435c76fc5..6b8e5a7778 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 4074926fad..4c2015a3cb 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 94dc13a53e..cfe7007b39 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 31ec80f1aa..7500d1c13e 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 d5dade01fd..689a1c8f21 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 42b9aa5e14..6f39221027 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 963e315303..c7e2d58c98 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 630129150f..5a52636c9f 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 e0bce34636..469c17f559 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 f747a1ed5a..c856c77ce5 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 98e47c6983..7f6f2463aa 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 b0a2cddcd2..45d8309656 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 5d866dea7a..4dd7e7008d 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 67c7b75942..3d0dfc0488 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 3ad25da6af..c9c5811b18 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 45d8309656..3dc2f1b7be 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 1dcb0af5a4..114de0035e 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 2ed5bc9178..2179090444 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 ad11f41174..4ec498fb8d 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 7707bed03a..7c9c09b727 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 f909fbcf45..8080a70e0c 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 5c4476312c..f588f0f5fd 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 6a2df852cf..0d9b1ee2fd 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 8080a70e0c..ccd3e2e42d 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 ccd3e2e42d..c33e800514 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 2179090444..63765c4771 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 3dc2f1b7be..f47a2b186b 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 c33e800514..34fc611826 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 63765c4771..b25c7dba5b 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 f47a2b186b..9a0e6f69dd 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 34fc611826..b1e5c69909 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 114de0035e..e192d501fe 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 b25c7dba5b..2b1d1f2da0 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 9a0e6f69dd..aaaa1bc967 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 e192d501fe..86be3f8954 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 ce3a3f4063..14f4b50b70 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 4dd7e7008d..803d010a91 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 17713b76a2..2598692f26 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 469c17f559..099d3a745b 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 4226a6d6c2..f957077136 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 aaaa1bc967..33364918ef 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 33364918ef..ded4c9b35d 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 a6edeef50c..168c4ebe22 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 b1e5c69909..34a1ad8574 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 2b1d1f2da0..be93c03ca8 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 ded4c9b35d..b0160b1e3e 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()