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 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() 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/CMakeLists.txt b/ORE-SWIG/CMakeLists.txt index 377c810004..34a1ad8574 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) @@ -31,22 +30,8 @@ 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) - - -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) 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}) @@ -56,15 +41,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}) - -include_directories(${Boost_INCLUDE_DIRS}) include_directories(${Python_INCLUDE_DIRS}) # Add to the list of link directories @@ -75,6 +55,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/") @@ -107,13 +88,13 @@ 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}) target_link_libraries(OREP ${OREA_LIB_NAME}) if(ORE_USE_ZLIB) - target_link_libraries(OREP ${ZLIB_LIBRARIES}) + 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/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/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/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}) 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/CMakeLists.txt b/OREAnalytics/CMakeLists.txt index 1dcb0af5a4..86be3f8954 100644 --- a/OREAnalytics/CMakeLists.txt +++ b/OREAnalytics/CMakeLists.txt @@ -9,28 +9,6 @@ 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}) @@ -46,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/OREAnalytics/orea/CMakeLists.txt b/OREAnalytics/orea/CMakeLists.txt index 2ed5bc9178..be93c03ca8 100644 --- a/OREAnalytics/orea/CMakeLists.txt +++ b/OREAnalytics/orea/CMakeLists.txt @@ -443,13 +443,10 @@ 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}) + target_link_libraries(${OREA_LIB_NAME} Boost::iostreams ZLIB::ZLIB) endif() if (QL_USE_PCH) 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/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=.) 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/CMakeLists.txt b/OREData/CMakeLists.txt index acfb5aa807..803d010a91 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 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}) @@ -30,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/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/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/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; } } 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/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/CMakeLists.txt b/QuantExt/CMakeLists.txt index 78253c3e16..099d3a745b 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 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}) @@ -63,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/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/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) { 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/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/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/commonSettings.cmake b/cmake/commonSettings.cmake index b0a2cddcd2..b0160b1e3e 100644 --- a/cmake/commonSettings.cmake +++ b/cmake/commonSettings.cmake @@ -1,3 +1,5 @@ +include_guard(GLOBAL) + include(CheckCXXCompilerFlag) include(CheckLinkerFlag) @@ -71,6 +73,7 @@ endif() # set compiler macro if zlib is enabled if(ORE_USE_ZLIB) + find_package(ZLIB REQUIRED) add_compile_definitions(ORE_USE_ZLIB) endif() @@ -239,8 +242,20 @@ endif() set(Boost_NO_WARN_NEW_VERSIONS ON) +# Avoid using Boost auto-linking +add_compile_definitions(BOOST_ALL_NO_LIB) + +# Find Boost components. +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) +endif() +find_package(Boost REQUIRED COMPONENTS ${BOOST_COMPONENT_LIST}) + if (MSVC) - find_package(Boost) if(Boost_VERSION_STRING LESS 1.84.0) add_compile_definitions(_WINVER=0x0601) add_compile_definitions(_WIN32_WINNT=0x0601) @@ -261,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() @@ -309,6 +323,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() @@ -320,3 +335,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() 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")