diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 79a13ba8d9..86020e2d6f 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,15 +1,15 @@ cmake_minimum_required(VERSION 3.14) # FetchContent_MakeAvailable # Version -set(ANTARES_VERSION_HI 9) -set(ANTARES_VERSION_LO 1) -set(ANTARES_VERSION_REVISION 0) +set(ANTARES_VERSION_HI 9) +set(ANTARES_VERSION_LO 1) +set(ANTARES_VERSION_REVISION 0) # Beta release set(ANTARES_BETA 0) set(ANTARES_RC 0) -set(ANTARES_VERSION_YEAR 2024) +set(ANTARES_VERSION_YEAR 2024) project(antares VERSION ${ANTARES_VERSION_HI}.${ANTARES_VERSION_LO}.${ANTARES_VERSION_REVISION}) @@ -26,7 +26,7 @@ file(READ "../ortools_tag" ORTOOLS_TAG) set(CMAKE_SKIP_PREPROCESSED_SOURCE_RULES true) set(CMAKE_SKIP_ASSEMBLY_SOURCE_RULES true) -set(CMAKE_INSTALL_RPATH $ORIGIN) +set(CMAKE_INSTALL_RPATH $ORIGIN) include(CheckCXXSourceCompiles) include(CheckIncludeFiles) @@ -39,7 +39,7 @@ set(CMAKE_CXX_STANDARD 20) if (DEFINED VCPKG_ROOT) include(${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake) -endif() +endif () #CMake function @@ -50,21 +50,21 @@ include("cmake/messages.cmake") set(ANTARES_VERSION_TAG "") -if(${ANTARES_BETA}) - set(ANTARES_VERSION_TAG "-beta${ANTARES_BETA}") -endif() +if (${ANTARES_BETA}) + set(ANTARES_VERSION_TAG "-beta${ANTARES_BETA}") +endif () -if(${ANTARES_RC}) - set (ANTARES_VERSION_TAG "-rc${ANTARES_RC}") -endif() +if (${ANTARES_RC}) + set(ANTARES_VERSION_TAG "-rc${ANTARES_RC}") +endif () # git SHA-1 find_package(Git QUIET) execute_process(COMMAND - "${GIT_EXECUTABLE}" describe --match=NeVeRmAtCh --abbrev=7 --always --dirty - WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" - OUTPUT_VARIABLE GIT_SHA1_SHORT - ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE) + "${GIT_EXECUTABLE}" describe --match=NeVeRmAtCh --abbrev=7 --always --dirty + WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" + OUTPUT_VARIABLE GIT_SHA1_SHORT + ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE) # Build Configuration set(ANTARES_TARGET "${CMAKE_BUILD_TYPE}") @@ -86,88 +86,88 @@ include("cmake/checks.cmake") if (ANTARES_LICENSE) - OMESSAGE("{antares} License : ${ANTARES_LICENSE}") -endif() + OMESSAGE("{antares} License : ${ANTARES_LICENSE}") +endif () -set(ANTARES_PRG_VERSION "${ANTARES_VERSION_HI}.${ANTARES_VERSION_LO}") +set(ANTARES_PRG_VERSION "${ANTARES_VERSION_HI}.${ANTARES_VERSION_LO}") #TODO : define if MSVC is used (check if can be removed) if ((WIN32 OR WIN64) AND (NOT MINGW AND NOT MSVC AND NOT CYGWIN AND NOT MSYS)) - set(MSVC 1) - set(ICC 1) -endif() + set(MSVC 1) + set(ICC 1) +endif () #Define which version is compiled (32bits or 64bits) if (CMAKE_SIZEOF_VOID_P EQUAL 8) - OMESSAGE(" Enabled 64bits instructions sets") - set(ANTARES_x86_64 true) - set(ANTARES_INSTALLER_ARCH "64bits") - set(ANTARES_INSTALLER_REDIST_ARCH "x64") - set(ANTARES_MANIFEST_ARCH "ia64") -else() - set(ANTARES_INSTALLER_ARCH "32bits") - set(ANTARES_INSTALLER_REDIST_ARCH "x86") - set(ANTARES_MANIFEST_ARCH "x86") -endif() + OMESSAGE(" Enabled 64bits instructions sets") + set(ANTARES_x86_64 true) + set(ANTARES_INSTALLER_ARCH "64bits") + set(ANTARES_INSTALLER_REDIST_ARCH "x64") + set(ANTARES_MANIFEST_ARCH "ia64") +else () + set(ANTARES_INSTALLER_ARCH "32bits") + set(ANTARES_INSTALLER_REDIST_ARCH "x86") + set(ANTARES_MANIFEST_ARCH "x86") +endif () #TODO : should not defined compiler name with a global variable if (WIN32) - if(MSVC) - set(COMPILER_NAME "vc14") - set(COMPILER_LIB_INCLUDE "vc") - else(MSVC) - set(COMPILER_NAME "gcc4.x") - set(COMPILER_LIB_INCLUDE "gcc") - endif(MSVC) -endif(WIN32) + if (MSVC) + set(COMPILER_NAME "vc14") + set(COMPILER_LIB_INCLUDE "vc") + else (MSVC) + set(COMPILER_NAME "gcc4.x") + set(COMPILER_LIB_INCLUDE "gcc") + endif (MSVC) +endif (WIN32) # # Beta # -if(NOT ANTARES_BETA EQUAL 0) - set(ANTARES_INSTALLER_BETA "-beta${ANTARES_BETA}") -else() - set(ANTARES_INSTALLER_BETA "") -endif() - -if(${ANTARES_RC}) - set(ANTARES_INSTALLER_RC "-rc${ANTARES_RC}") -else() - set(ANTARES_INSTALLER_RC "") -endif() +if (NOT ANTARES_BETA EQUAL 0) + set(ANTARES_INSTALLER_BETA "-beta${ANTARES_BETA}") +else () + set(ANTARES_INSTALLER_BETA "") +endif () + +if (${ANTARES_RC}) + set(ANTARES_INSTALLER_RC "-rc${ANTARES_RC}") +else () + set(ANTARES_INSTALLER_RC "") +endif () OMESSAGE("") OMESSAGE("") #Display Build Configuration (debug or release) -if("${CMAKE_BUILD_TYPE}" STREQUAL "Release") - OMESSAGE("{antares} Build Configuration: RELEASE") -else() - OMESSAGE("{antares} Build Configuration: DEBUG") -endif() +if ("${CMAKE_BUILD_TYPE}" STREQUAL "Release") + OMESSAGE("{antares} Build Configuration: RELEASE") +else () + OMESSAGE("{antares} Build Configuration: DEBUG") +endif () # # Yuni Framework # -if("${CMAKE_BUILD_TYPE}" STREQUAL "Release") - set(YUNI_TARGET_MODE "release") - set(ANTARES_VERSION_TARGET "release") -else() - set(YUNI_TARGET_MODE "debug") - set(ANTARES_VERSION_TARGET "debug") -endif() +if ("${CMAKE_BUILD_TYPE}" STREQUAL "Release") + set(YUNI_TARGET_MODE "release") + set(ANTARES_VERSION_TARGET "release") +else () + set(YUNI_TARGET_MODE "debug") + set(ANTARES_VERSION_TARGET "debug") +endif () set(CODE_COVERAGE FALSE CACHE BOOL "Enable code coverage") if (CODE_COVERAGE) - # if code-coverage is ON, force tests build - set(BUILD_TESTING ON) + # if code-coverage is ON, force tests build + set(BUILD_TESTING ON) - include("cmake/CodeCoverage.cmake") - code_coverage(NAME code-coverage - OUTPUT_DIR coverage - EXCLUDE_DIRS tests) + include("cmake/CodeCoverage.cmake") + code_coverage(NAME code-coverage + OUTPUT_DIR coverage + EXCLUDE_DIRS tests) endif () # TODO : removed to be confirmed : old fashion CMake All libraries will be stored in /bin directory @@ -194,37 +194,37 @@ message(STATUS "With yaml-cpp: ${WITH_YAMLCPP}") option(BUILD_MERSENNE_TWISTER_PYBIND11 "Build pybind11 bindings for Mersenne-Twister" OFF) if (${BUILD_MERSENNE_TWISTER_PYBIND11}) find_package(pybind11 REQUIRED) -endif() +endif () #Define install directory if (NOT DEPS_INSTALL_DIR) SET(DEPS_INSTALL_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../rte-antares-deps-${CMAKE_BUILD_TYPE}) -else() - if(NOT IS_ABSOLUTE ${DEPS_INSTALL_DIR}) +else () + if (NOT IS_ABSOLUTE ${DEPS_INSTALL_DIR}) SET(DEPS_INSTALL_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../${DEPS_INSTALL_DIR}) - endif() -endif() + endif () +endif () # Add DEPS_INSTALL_DIR with antares-xpansion CMAKE_BUILD_TYPE if ("${CMAKE_BUILD_TYPE}" STREQUAL "Release") - string(REPLACE ${CMAKE_BUILD_TYPE} Release - DEPS_INSTALL_DIR_XPANSION - ${DEPS_INSTALL_DIR}) + string(REPLACE ${CMAKE_BUILD_TYPE} Release + DEPS_INSTALL_DIR_XPANSION + ${DEPS_INSTALL_DIR}) - list(APPEND CMAKE_PREFIX_PATH ${DEPS_INSTALL_DIR_XPANSION}) - -elseif("${CMAKE_BUILD_TYPE}" STREQUAL "debug") + list(APPEND CMAKE_PREFIX_PATH ${DEPS_INSTALL_DIR_XPANSION}) - string(REPLACE ${CMAKE_BUILD_TYPE} Debug - DEPS_INSTALL_DIR_XPANSION - ${DEPS_INSTALL_DIR}) - - list(APPEND CMAKE_PREFIX_PATH ${DEPS_INSTALL_DIR_XPANSION}) +elseif ("${CMAKE_BUILD_TYPE}" STREQUAL "debug") -endif() + string(REPLACE ${CMAKE_BUILD_TYPE} Debug + DEPS_INSTALL_DIR_XPANSION + ${DEPS_INSTALL_DIR}) + + list(APPEND CMAKE_PREFIX_PATH ${DEPS_INSTALL_DIR_XPANSION}) + +endif () list(APPEND CMAKE_PREFIX_PATH ${DEPS_INSTALL_DIR}) message(STATUS "CMAKE_PREFIX_PATH : ${CMAKE_PREFIX_PATH}") @@ -233,77 +233,77 @@ message(STATUS "CMAKE_PREFIX_PATH : ${CMAKE_PREFIX_PATH}") add_subdirectory(antares-deps) #Add needed definition in case of external dependencies compilation -include (antares-deps/cmake/additionnal-definitions.cmake) +include(antares-deps/cmake/additionnal-definitions.cmake) #Boost header libraries find_package(Boost REQUIRED) #TODO : Add ZLIB if VCPKG used why is this needed -if (VCPKG_TOOLCHAIN) +if (VCPKG_TOOLCHAIN) #zlib find_package(ZLIB REQUIRED) -endif() +endif () #Sirius solver -if(POLICY CMP0074) - cmake_policy(SET CMP0074 NEW) -endif() +if (POLICY CMP0074) + cmake_policy(SET CMP0074 NEW) +endif () if (VCPKG_TOOLCHAIN) - list(APPEND CMAKE_PREFIX_PATH "${sirius_solver_ROOT}") - list(APPEND CMAKE_PREFIX_PATH "${ortools_ROOT}") -endif() + list(APPEND CMAKE_PREFIX_PATH "${sirius_solver_ROOT}") + list(APPEND CMAKE_PREFIX_PATH "${ortools_ROOT}") +endif () find_package(sirius_solver) if (NOT sirius_solver_FOUND) - message (FATAL_ERROR "Sirius solver not found. Sirius solver can be compiled with -DBUILD_sirius=ON or you can specify previous dependency install directory with -DCMAKE_PREFIX_PATH or -DDEPS_INSTALL_DIR") -endif() + message(FATAL_ERROR "Sirius solver not found. Sirius solver can be compiled with -DBUILD_sirius=ON or you can specify previous dependency install directory with -DCMAKE_PREFIX_PATH or -DDEPS_INSTALL_DIR") +endif () find_package(ortools) -if(NOT ortools_FOUND OR BUILD_ORTOOLS) -message(STATUS "OR-Tools tag ${ORTOOLS_TAG}") - FetchContent_Declare(ortools - GIT_REPOSITORY "https://github.com/rte-france/or-tools" - GIT_TAG ${ORTOOLS_TAG} - GIT_SHALLOW TRUE +if (NOT ortools_FOUND OR BUILD_ORTOOLS) + message(STATUS "OR-Tools tag ${ORTOOLS_TAG}") + FetchContent_Declare(ortools + GIT_REPOSITORY "https://github.com/rte-france/or-tools" + GIT_TAG ${ORTOOLS_TAG} + GIT_SHALLOW TRUE ) - # Pass options to OR-Tools's CMake - set(BUILD_DEPS "ON" CACHE INTERNAL "") - set(BUILD_SAMPLES "OFF" CACHE INTERNAL "") - set(BUILD_FLATZINC "OFF" CACHE INTERNAL "") - set(BUILD_EXAMPLES "OFF" CACHE INTERNAL "") - set(USE_SCIP "ON" CACHE INTERNAL "") - set(USE_GLPK "ON" CACHE INTERNAL "") - # We build OR-Tools as a static lib. Cyclic dependencies are detected - # without this flag. - set(BUILD_SHARED_LIBS "OFF" CACHE INTERNAL "") - # In mode optimization error analysis, we call Sirius through or-tools - # So we need to activate Sirius in or-tools configuration (OFF by default) - set(USE_SIRIUS "ON" CACHE INTERNAL "") - - FetchContent_MakeAvailable(ortools) -endif() + # Pass options to OR-Tools's CMake + set(BUILD_DEPS "ON" CACHE INTERNAL "") + set(BUILD_SAMPLES "OFF" CACHE INTERNAL "") + set(BUILD_FLATZINC "OFF" CACHE INTERNAL "") + set(BUILD_EXAMPLES "OFF" CACHE INTERNAL "") + set(USE_SCIP "ON" CACHE INTERNAL "") + set(USE_GLPK "ON" CACHE INTERNAL "") + # We build OR-Tools as a static lib. Cyclic dependencies are detected + # without this flag. + set(BUILD_SHARED_LIBS "OFF" CACHE INTERNAL "") + # In mode optimization error analysis, we call Sirius through or-tools + # So we need to activate Sirius in or-tools configuration (OFF by default) + set(USE_SIRIUS "ON" CACHE INTERNAL "") + + FetchContent_MakeAvailable(ortools) +endif () find_package(minizip-ng) if (minizip-ng_FOUND) - add_library(MINIZIP::minizip ALIAS MINIZIP::minizip-ng) + add_library(MINIZIP::minizip ALIAS MINIZIP::minizip-ng) else () - find_package(minizip) - if (minizip_FOUND) - message (STATUS "Found minizip (not minizip-ng).") - else () - message (FATAL_ERROR "Minizip not found.") - endif () + find_package(minizip) + if (minizip_FOUND) + message(STATUS "Found minizip (not minizip-ng).") + else () + message(FATAL_ERROR "Minizip not found.") + endif () endif () #wxWidget not needed for all library find is done in ui CMakeLists.txt -if (VCPKG_TOOLCHAIN AND NOT BUILD_wxWidgets) +if (VCPKG_TOOLCHAIN AND NOT BUILD_wxWidgets) #Add cmake directory to CMAKE_MODULE_PATH to use specific FindwxWidgets package needed for vcpkg list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/wxWidgets") -endif() +endif () # TODO : review Standard Settings include(cmake/common-settings.cmake) @@ -312,7 +312,7 @@ add_subdirectory(config) # Configure config.h with current ANTARES version configure_file("${CMAKE_CURRENT_SOURCE_DIR}/config/config.h.in" - "${CMAKE_CURRENT_SOURCE_DIR}/config/include/antares/config/config.h") + "${CMAKE_CURRENT_SOURCE_DIR}/config/include/antares/config/config.h") # Yuni Framework configure_file("cmake/ProfileBuild.template.cmake" "ext/yuni/src/ProfileBuild.cmake") @@ -322,128 +322,126 @@ OMESSAGE("") # empty line # Sub Directories add_subdirectory(api) -add_subdirectory(libs) #antares-core fswalker +add_subdirectory(libs) #antares-core fswalker -if(BUILD_UI) - add_subdirectory(ui) #all antares ui libs + antares simulator -endif() +if (BUILD_UI) + add_subdirectory(ui) #all antares ui libs + antares simulator +endif () -add_subdirectory(solver) #antares solver and all associated libs -add_subdirectory(analyzer) #antares analyser +add_subdirectory(solver) #antares solver and all associated libs +add_subdirectory(analyzer) #antares analyser # Tools if (BUILD_TOOLS) -add_subdirectory(tools) #All antares tools -endif() + add_subdirectory(tools) #All antares tools +endif () # Tests # Not setting BUILD_TESTING as a command line argument is equivalent to use -DBUILD_TESTING=OFF # To build tests, use -DBUILD_TESTING=ON option(BUILD_TESTING "Activates unit tests building" OFF) -if(BUILD_TESTING) - # include(CTest) # calls enable_testing() and turns BUILD_TESTING to ON by default (among other useful things) - enable_testing() +if (BUILD_TESTING) + # include(CTest) # calls enable_testing() and turns BUILD_TESTING to ON by default (among other useful things) + enable_testing() - add_subdirectory(tests) -endif() + add_subdirectory(tests) +endif () OMESSAGE("") - - # Informations for NSIS -if(WIN32 OR WIN64) - if(MSVC) - if("${CMAKE_BUILD_TYPE}" STREQUAL "Release") - set(NSIS_TARGET "Release") - else() - set(NSIS_TARGET "Debug") - endif() - set(COMPILER_MARK "v") - #set(COMPILER_INCLUDE "vs9") - else(MSVC) - set(NSIS_TARGET "") - set(COMPILER_MARK "m") - set(COMPILER_INCLUDE "mingw") - endif(MSVC) - - set(CPACK_MODULE_PATH ${CMAKE_CURRENT_BINARY_DIR}/distrib/win32 ${CPACK_MODULE_PATH}) - - # Configure file with custom definitions for NSIS. - configure_file( - ${PROJECT_SOURCE_DIR}/distrib/win32/version.cmake - ${CMAKE_CURRENT_BINARY_DIR}/distrib/win32/version.nsh - ) - - configure_file( - ${PROJECT_SOURCE_DIR}/distrib/win32/build.template.cmake - ${CMAKE_CURRENT_BINARY_DIR}/distrib/win32/build.nsh - ) - - configure_file( - ${PROJECT_SOURCE_DIR}/distrib/win32/make-zip-from-installer.cmake - ${CMAKE_CURRENT_BINARY_DIR}/distrib/win32/make-zip-from-installer.bat - ) - - SET(ANTARES_BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR}) - - # Define system libraries so NSIS can package these files - include (InstallRequiredSystemLibraries) - - #Convert to native and add double quote to be used in NSIS package - foreach(SYSTEM_RUNTIME_LIB ${CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS}) - file(TO_NATIVE_PATH ${SYSTEM_RUNTIME_LIB} SYSTEM_RUNTIME_LIB_NATIVE) - - list(APPEND SYSTEM_RUNTIME_LIBS_NATIVE \"${SYSTEM_RUNTIME_LIB_NATIVE}\") - endforeach() - - #Replace ; by space so SYSTEM_RUNTIME_LIBS_STR can be used in File function in NSIS file - string (REPLACE ";" " " SYSTEM_RUNTIME_LIBS_STR "${SYSTEM_RUNTIME_LIBS_NATIVE}") - - configure_file( - ${PROJECT_SOURCE_DIR}/distrib/win32/NSIS.template.in - ${CMAKE_CURRENT_BINARY_DIR}/distrib/win32/NSIS.template.in - @ONLY - ) - - #Define cpack install script to checkout examples - configure_file( - ${PROJECT_SOURCE_DIR}/distrib/CMakeLists.txt.in - ${CMAKE_CURRENT_BINARY_DIR}/distrib/CMakeLists.txt - @ONLY - ) - - set(CPACK_INSTALL_SCRIPT ${CMAKE_CURRENT_BINARY_DIR}/distrib/CMakeLists.txt) - - #Set package name from CMake and antares variables - set(CPACK_PACKAGE_FILE_NAME "rte-antares-${ANTARES_VERSION_HI}.${ANTARES_VERSION_LO}.${ANTARES_VERSION_REVISION}${ANTARES_VERSION_TAG}-installer-${ANTARES_INSTALLER_ARCH}") - - -else() - - if(CMAKE_SYSTEM_NAME MATCHES "Linux") +if (WIN32 OR WIN64) + if (MSVC) + if ("${CMAKE_BUILD_TYPE}" STREQUAL "Release") + set(NSIS_TARGET "Release") + else () + set(NSIS_TARGET "Debug") + endif () + set(COMPILER_MARK "v") + #set(COMPILER_INCLUDE "vs9") + else (MSVC) + set(NSIS_TARGET "") + set(COMPILER_MARK "m") + set(COMPILER_INCLUDE "mingw") + endif (MSVC) + + set(CPACK_MODULE_PATH ${CMAKE_CURRENT_BINARY_DIR}/distrib/win32 ${CPACK_MODULE_PATH}) + + # Configure file with custom definitions for NSIS. + configure_file( + ${PROJECT_SOURCE_DIR}/distrib/win32/version.cmake + ${CMAKE_CURRENT_BINARY_DIR}/distrib/win32/version.nsh + ) + + configure_file( + ${PROJECT_SOURCE_DIR}/distrib/win32/build.template.cmake + ${CMAKE_CURRENT_BINARY_DIR}/distrib/win32/build.nsh + ) + + configure_file( + ${PROJECT_SOURCE_DIR}/distrib/win32/make-zip-from-installer.cmake + ${CMAKE_CURRENT_BINARY_DIR}/distrib/win32/make-zip-from-installer.bat + ) + + SET(ANTARES_BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR}) + + # Define system libraries so NSIS can package these files + include(InstallRequiredSystemLibraries) + + #Convert to native and add double quote to be used in NSIS package + foreach (SYSTEM_RUNTIME_LIB ${CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS}) + file(TO_NATIVE_PATH ${SYSTEM_RUNTIME_LIB} SYSTEM_RUNTIME_LIB_NATIVE) + + list(APPEND SYSTEM_RUNTIME_LIBS_NATIVE \"${SYSTEM_RUNTIME_LIB_NATIVE}\") + endforeach () + + #Replace ; by space so SYSTEM_RUNTIME_LIBS_STR can be used in File function in NSIS file + string(REPLACE ";" " " SYSTEM_RUNTIME_LIBS_STR "${SYSTEM_RUNTIME_LIBS_NATIVE}") + + configure_file( + ${PROJECT_SOURCE_DIR}/distrib/win32/NSIS.template.in + ${CMAKE_CURRENT_BINARY_DIR}/distrib/win32/NSIS.template.in + @ONLY + ) + + #Define cpack install script to checkout examples + configure_file( + ${PROJECT_SOURCE_DIR}/distrib/CMakeLists.txt.in + ${CMAKE_CURRENT_BINARY_DIR}/distrib/CMakeLists.txt + @ONLY + ) + + set(CPACK_INSTALL_SCRIPT ${CMAKE_CURRENT_BINARY_DIR}/distrib/CMakeLists.txt) + + #Set package name from CMake and antares variables + set(CPACK_PACKAGE_FILE_NAME "rte-antares-${ANTARES_VERSION_HI}.${ANTARES_VERSION_LO}.${ANTARES_VERSION_REVISION}${ANTARES_VERSION_TAG}-installer-${ANTARES_INSTALLER_ARCH}") + + +else () + + if (CMAKE_SYSTEM_NAME MATCHES "Linux") get_linux_lsb_release_information() message(STATUS "Linux ${LSB_RELEASE_ID_SHORT} ${LSB_RELEASE_VERSION_SHORT} ${LSB_RELEASE_CODENAME_SHORT}") - set(CPACK_SYSTEM_NAME "${LSB_RELEASE_ID_SHORT}-${LSB_RELEASE_VERSION_SHORT}") - endif() - - #For now only test deb, need to define several CPACK variable - set(CPACK_PROJECT_NAME "antares-deb-test") - set(CPACK_DEBIAN_PACKAGE_MAINTAINER "RTE") - set(CPACK_DEBIAN_PACKAGE_NAME "antares") - set(CPACK_PACKAGE_VERSION_MAJOR ${ANTARES_VERSION_HI}) - set(CPACK_PACKAGE_VERSION_MINOR ${ANTARES_VERSION_LO}) - set(CPACK_PACKAGE_VERSION_PATCH ${ANTARES_VERSION_REVISION}${ANTARES_VERSION_TAG}) - - set(CPACK_DEBIAN_PACKAGE_DEPENDS "libwxgtk3.0-gtk3-0v5 | libwxgtk3.2-dev") + set(CPACK_SYSTEM_NAME "${LSB_RELEASE_ID_SHORT}-${LSB_RELEASE_VERSION_SHORT}") + endif () + + #For now only test deb, need to define several CPACK variable + set(CPACK_PROJECT_NAME "antares-deb-test") + set(CPACK_DEBIAN_PACKAGE_MAINTAINER "RTE") + set(CPACK_DEBIAN_PACKAGE_NAME "antares") + set(CPACK_PACKAGE_VERSION_MAJOR ${ANTARES_VERSION_HI}) + set(CPACK_PACKAGE_VERSION_MINOR ${ANTARES_VERSION_LO}) + set(CPACK_PACKAGE_VERSION_PATCH ${ANTARES_VERSION_REVISION}${ANTARES_VERSION_TAG}) + + set(CPACK_DEBIAN_PACKAGE_DEPENDS "libwxgtk3.0-gtk3-0v5 | libwxgtk3.2-dev") set(CPACK_RPM_PACKAGE_REQUIRES "wxGTK3") set(CPACK_RPM_PACKAGE_AUTOREQPROV "0") - configure_file("distrib/unix/packages.cmake" "distrib/unix/packages.sh") + configure_file("distrib/unix/packages.cmake" "distrib/unix/packages.sh") -endif() +endif () # Load packaging facilities. include(CPack) diff --git a/src/tests/end-to-end/binding_constraints/test_binding_constraints.cpp b/src/tests/end-to-end/binding_constraints/test_binding_constraints.cpp index 3d5d833f8c..846009856e 100644 --- a/src/tests/end-to-end/binding_constraints/test_binding_constraints.cpp +++ b/src/tests/end-to-end/binding_constraints/test_binding_constraints.cpp @@ -20,8 +20,7 @@ */ #include // Fix for Boost < 1.67 -#define BOOST_TEST_MODULE test-end-to-end tests_binding_constraints -#define BOOST_TEST_DYN_LINK +#define BOOST_TEST_MODULE test - end - to - end tests_binding_constraints #define WIN32_LEAN_AND_MEAN #include #include diff --git a/src/tests/end-to-end/simple_study/simple-study.cpp b/src/tests/end-to-end/simple_study/simple-study.cpp index 3f6dc52ac5..50482333b2 100644 --- a/src/tests/end-to-end/simple_study/simple-study.cpp +++ b/src/tests/end-to-end/simple_study/simple-study.cpp @@ -20,8 +20,7 @@ */ #include // Fix for Boost < 1.67 -#define BOOST_TEST_MODULE test-end-to-end tests -#define BOOST_TEST_DYN_LINK +#define BOOST_TEST_MODULE test - end - to - end tests #include #include diff --git a/src/tests/src/api_internal/test_api.cpp b/src/tests/src/api_internal/test_api.cpp index 7a6df5e276..9dd256315d 100644 --- a/src/tests/src/api_internal/test_api.cpp +++ b/src/tests/src/api_internal/test_api.cpp @@ -20,42 +20,48 @@ */ #define BOOST_TEST_MODULE test api -#define BOOST_TEST_DYN_LINK #define WIN32_LEAN_AND_MEAN -#include #include + +#include + #include "API.h" #include "in-memory-study.h" -class InMemoryStudyLoader : public Antares::IStudyLoader +class InMemoryStudyLoader: public Antares::IStudyLoader { public: - explicit InMemoryStudyLoader(bool success = true) : success_(success) {}; - [[nodiscard]] std::unique_ptr load() const override { - if (!success_) { - return nullptr; - } - StudyBuilder builder; - builder.addAreaToStudy("area1"); - builder.addAreaToStudy("area2"); - builder.study->initializeRuntimeInfos(); - builder.study->parameters.resultFormat = ResultFormat::inMemory; - builder.study->prepareOutput(); - return std::move(builder.study); - }; + explicit InMemoryStudyLoader(bool success = true): + success_(success){}; + + [[nodiscard]] std::unique_ptr load() const override + { + if (!success_) + { + return nullptr; + } + StudyBuilder builder; + builder.addAreaToStudy("area1"); + builder.addAreaToStudy("area2"); + builder.study->initializeRuntimeInfos(); + builder.study->parameters.resultFormat = ResultFormat::inMemory; + builder.study->prepareOutput(); + return std::move(builder.study); + } + bool success_ = true; }; - BOOST_AUTO_TEST_CASE(simulation_path_points_to_results) { Antares::API::APIInternal api; auto study_loader = std::make_unique(); auto results = api.run(*study_loader.get()); BOOST_CHECK_EQUAL(results.simulationPath, std::filesystem::path{"no_output"}); - //Testing for "no_output" is a bit weird, but it's the only way to test this without actually running the simulation + // Testing for "no_output" is a bit weird, but it's the only way to test this without actually + // running the simulation } BOOST_AUTO_TEST_CASE(api_run_contains_antares_problem) @@ -77,7 +83,7 @@ BOOST_AUTO_TEST_CASE(result_failure_when_study_is_null) BOOST_CHECK(results.error); } -//Test where data in problems are consistant with data in study +// Test where data in problems are consistant with data in study BOOST_AUTO_TEST_CASE(result_contains_problems) { Antares::API::APIInternal api; @@ -87,4 +93,4 @@ BOOST_AUTO_TEST_CASE(result_contains_problems) BOOST_CHECK(!results.antares_problems.empty()); BOOST_CHECK(!results.error); BOOST_CHECK_EQUAL(results.antares_problems.weeklyProblems.size(), 52); -} \ No newline at end of file +} diff --git a/src/tests/src/api_lib/test_api.cpp b/src/tests/src/api_lib/test_api.cpp index cbc65ea68a..ca3c86dd7a 100644 --- a/src/tests/src/api_lib/test_api.cpp +++ b/src/tests/src/api_lib/test_api.cpp @@ -20,16 +20,17 @@ */ #define BOOST_TEST_MODULE test api -#define BOOST_TEST_DYN_LINK #define WIN32_LEAN_AND_MEAN #include + #include "antares/api/solver.h" -BOOST_AUTO_TEST_CASE(result_failure_when_study_path_invalid) { +BOOST_AUTO_TEST_CASE(result_failure_when_study_path_invalid) +{ using namespace std::string_literals; auto results = Antares::API::PerformSimulation("dummy"s); BOOST_CHECK(results.error); BOOST_CHECK(!results.error->reason.empty()); -} \ No newline at end of file +} diff --git a/src/tests/src/libs/antares/benchmarking/test_duration_collector.cpp b/src/tests/src/libs/antares/benchmarking/test_duration_collector.cpp index bd1585d6da..20e5d09e12 100644 --- a/src/tests/src/libs/antares/benchmarking/test_duration_collector.cpp +++ b/src/tests/src/libs/antares/benchmarking/test_duration_collector.cpp @@ -20,7 +20,6 @@ */ #define BOOST_TEST_MODULE test - benchmarking -#define BOOST_TEST_DYN_LINK #include #include diff --git a/src/tests/src/libs/antares/concurrency/test_concurrency.cpp b/src/tests/src/libs/antares/concurrency/test_concurrency.cpp index 619acefa77..7964ca575d 100644 --- a/src/tests/src/libs/antares/concurrency/test_concurrency.cpp +++ b/src/tests/src/libs/antares/concurrency/test_concurrency.cpp @@ -21,7 +21,6 @@ #include // Fix for Boost < 1.67 #define BOOST_TEST_MODULE test - concurrency tests -#define BOOST_TEST_DYN_LINK #include #include diff --git a/src/tests/src/libs/antares/inifile/test_inifile_io.cpp b/src/tests/src/libs/antares/inifile/test_inifile_io.cpp index fef8c4a160..484813d3bf 100644 --- a/src/tests/src/libs/antares/inifile/test_inifile_io.cpp +++ b/src/tests/src/libs/antares/inifile/test_inifile_io.cpp @@ -19,7 +19,6 @@ * along with Antares_Simulator. If not, see . */ #define BOOST_TEST_MODULE "test inifile IO" -#define BOOST_TEST_DYN_LINK #include #include "antares/inifile/inifile.h" diff --git a/src/tests/src/libs/antares/test_utils.cpp b/src/tests/src/libs/antares/test_utils.cpp index 72b505f8bf..4edc6f4a57 100644 --- a/src/tests/src/libs/antares/test_utils.cpp +++ b/src/tests/src/libs/antares/test_utils.cpp @@ -19,7 +19,6 @@ * along with Antares_Simulator. If not, see . */ #define BOOST_TEST_MODULE test utils -#define BOOST_TEST_DYN_LINK #include #include diff --git a/src/tests/src/libs/antares/writer/test_writer.cpp b/src/tests/src/libs/antares/writer/test_writer.cpp index c711c3c411..4d0bc03f46 100644 --- a/src/tests/src/libs/antares/writer/test_writer.cpp +++ b/src/tests/src/libs/antares/writer/test_writer.cpp @@ -21,7 +21,6 @@ #include // Fix for Boost < 1.67 #define BOOST_TEST_MODULE test - writer tests -#define BOOST_TEST_DYN_LINK #include #include diff --git a/src/tests/src/solver/lps/test_lps.cpp b/src/tests/src/solver/lps/test_lps.cpp index 89a32e49ee..abb000f117 100644 --- a/src/tests/src/solver/lps/test_lps.cpp +++ b/src/tests/src/solver/lps/test_lps.cpp @@ -20,11 +20,11 @@ */ #define BOOST_TEST_MODULE test translator -#define BOOST_TEST_DYN_LINK #define WIN32_LEAN_AND_MEAN #include + #include using namespace Antares::Solver; @@ -58,19 +58,21 @@ BOOST_AUTO_TEST_CASE(lps_with_both_constant_and_weekly_data_is_not_empty) BOOST_CHECK(!lps.empty()); } -BOOST_AUTO_TEST_CASE(replace_const_data) { - LpsFromAntares lps; - ConstantDataFromAntares var; - var.VariablesCount = 42; - lps.setConstantData(var); - BOOST_CHECK(lps.constantProblemData.VariablesCount == 42); +BOOST_AUTO_TEST_CASE(replace_const_data) +{ + LpsFromAntares lps; + ConstantDataFromAntares var; + var.VariablesCount = 42; + lps.setConstantData(var); + BOOST_CHECK(lps.constantProblemData.VariablesCount == 42); } -//Add weekly data for week 1 year 1 -BOOST_AUTO_TEST_CASE(add_weekly_data_for_week_1_year_1) { +// Add weekly data for week 1 year 1 +BOOST_AUTO_TEST_CASE(add_weekly_data_for_week_1_year_1) +{ LpsFromAntares lps; WeeklyDataFromAntares w; w.RHS.push_back(43); lps.addWeeklyData({1, 1}, w); BOOST_CHECK(lps.weeklyData({1, 1}).RHS.size() != WeeklyDataFromAntares().RHS.size()); -} \ No newline at end of file +} diff --git a/src/tests/src/solver/optimisation/translator/test_translator.cpp b/src/tests/src/solver/optimisation/translator/test_translator.cpp index e0b30d9e1e..763de166cb 100644 --- a/src/tests/src/solver/optimisation/translator/test_translator.cpp +++ b/src/tests/src/solver/optimisation/translator/test_translator.cpp @@ -20,31 +20,36 @@ */ #define BOOST_TEST_MODULE test translator -#define BOOST_TEST_DYN_LINK #define WIN32_LEAN_AND_MEAN +#include + #include + #include -#include #include "antares/solver/optimisation/opt_period_string_generator_base.h" using namespace Antares::Solver; -class StubOptPeriodStringGenerator : public OptPeriodStringGenerator { +class StubOptPeriodStringGenerator: public OptPeriodStringGenerator +{ public: - std::string to_string() const override { + std::string to_string() const override + { return "Plop"; } }; -BOOST_AUTO_TEST_CASE(null_hebdo_is_empty_lps) { +BOOST_AUTO_TEST_CASE(null_hebdo_is_empty_lps) +{ HebdoProblemToLpsTranslator translator; auto ret = translator.translate(nullptr, std::string()); BOOST_CHECK(ret == WeeklyDataFromAntares()); } -BOOST_AUTO_TEST_CASE(non_null_hebdo_returns_non_empty_lps) { +BOOST_AUTO_TEST_CASE(non_null_hebdo_returns_non_empty_lps) +{ HebdoProblemToLpsTranslator translator; PROBLEME_ANTARES_A_RESOUDRE problemHebdo; problemHebdo.CoutLineaire.push_back(45); @@ -52,7 +57,8 @@ BOOST_AUTO_TEST_CASE(non_null_hebdo_returns_non_empty_lps) { BOOST_CHECK(ret != WeeklyDataFromAntares()); } -BOOST_AUTO_TEST_CASE(Data_properly_copied) { +BOOST_AUTO_TEST_CASE(Data_properly_copied) +{ HebdoProblemToLpsTranslator translator; PROBLEME_ANTARES_A_RESOUDRE problemHebdo; problemHebdo.CoutLineaire = {0, 1, 2}; @@ -72,16 +78,18 @@ BOOST_AUTO_TEST_CASE(Data_properly_copied) { BOOST_CHECK(ret.constraints == problemHebdo.NomDesContraintes); } -BOOST_AUTO_TEST_CASE(translate_sens) { +BOOST_AUTO_TEST_CASE(translate_sens) +{ HebdoProblemToLpsTranslator translator; PROBLEME_ANTARES_A_RESOUDRE problemHebdo; problemHebdo.Sens = "<=>"; auto ret = translator.translate(&problemHebdo, std::string()); - BOOST_CHECK(ret.Direction == std::vector({'<','=','>'})); + BOOST_CHECK(ret.Direction == std::vector({'<', '=', '>'})); } -BOOST_AUTO_TEST_CASE(translate_name_is_filled) { +BOOST_AUTO_TEST_CASE(translate_name_is_filled) +{ HebdoProblemToLpsTranslator translator; PROBLEME_ANTARES_A_RESOUDRE problemHebdo; @@ -89,7 +97,8 @@ BOOST_AUTO_TEST_CASE(translate_name_is_filled) { BOOST_CHECK(!ret.name.empty()); } -BOOST_AUTO_TEST_CASE(translate_name_is_properly_filled) { +BOOST_AUTO_TEST_CASE(translate_name_is_properly_filled) +{ HebdoProblemToLpsTranslator translator; PROBLEME_ANTARES_A_RESOUDRE problemHebdo; @@ -97,13 +106,15 @@ BOOST_AUTO_TEST_CASE(translate_name_is_properly_filled) { BOOST_CHECK_EQUAL(ret.name, "problem-Plop--optim-nb-1.mps"); } -BOOST_AUTO_TEST_CASE(empty_problem_empty_const_data) { - HebdoProblemToLpsTranslator translator; - auto ret = translator.commonProblemData(nullptr); - BOOST_CHECK(ret == ConstantDataFromAntares()); +BOOST_AUTO_TEST_CASE(empty_problem_empty_const_data) +{ + HebdoProblemToLpsTranslator translator; + auto ret = translator.commonProblemData(nullptr); + BOOST_CHECK(ret == ConstantDataFromAntares()); } -BOOST_AUTO_TEST_CASE(common_data_properly_copied) { +BOOST_AUTO_TEST_CASE(common_data_properly_copied) +{ HebdoProblemToLpsTranslator translator; PROBLEME_ANTARES_A_RESOUDRE problemHebdo; problemHebdo.NombreDeVariables = 1; @@ -114,8 +125,6 @@ BOOST_AUTO_TEST_CASE(common_data_properly_copied) { problemHebdo.CoefficientsDeLaMatriceDesContraintes = {0, 1, 2, 3, 4, 5}; problemHebdo.IndicesColonnes = {0, 1, 2, 3, 4, 5}; - - auto ret = translator.commonProblemData(&problemHebdo); BOOST_CHECK_EQUAL(ret.VariablesCount, problemHebdo.NombreDeVariables); BOOST_CHECK_EQUAL(ret.ConstraintesCount, problemHebdo.NombreDeContraintes); @@ -125,7 +134,7 @@ BOOST_AUTO_TEST_CASE(common_data_properly_copied) { BOOST_CHECK(std::ranges::equal(ret.Mdeb, problemHebdo.IndicesDebutDeLigne)); } -//throw exception if NombreDeVariables is 0 +// throw exception if NombreDeVariables is 0 BOOST_AUTO_TEST_CASE(throw_exception_if_NombreDeVariables_is_0) { HebdoProblemToLpsTranslator translator; @@ -164,7 +173,7 @@ BOOST_AUTO_TEST_CASE(throw_exception_if_NombreDeTermesDesLignes_out_of_bound) BOOST_CHECK_THROW(translator.commonProblemData(&problemHebdo), std::runtime_error); } -//NombreDeCoefficients +// NombreDeCoefficients BOOST_AUTO_TEST_CASE(NombreDeCoefficients_is_properly_computed) { HebdoProblemToLpsTranslator translator; @@ -179,4 +188,3 @@ BOOST_AUTO_TEST_CASE(NombreDeCoefficients_is_properly_computed) auto ret = translator.commonProblemData(&problemHebdo); BOOST_CHECK_EQUAL(ret.CoeffCount, 9); } -