-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add options to handle static and static runtime builds. #299
Draft
gautierbureau
wants to merge
32
commits into
main
Choose a base branch
from
static_runtime_msvc
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
e621f84
Add substation in error message (#237)
sebalaig 3755724
Make sure xml serializer is not null when writing extensions (#239)
sebalaig 7ffef53
Invalidate cache after an element is removed from NodeBreakerVoltageL…
sebalaig 1ecaa31
Update current version to 1.4.0 (#252)
sebalaig 7ec5fe4
[IIDM v1.4] Add ThreeWindingsTransformer::getLegs()
sebalaig 3a08d4e
[IIDM v1.4] Aliases by type (#243) (#255)
sebalaig f37484e
[IIDM v1.4] Add Extendable::getExtensionByName (#210) (#259)
sebalaig 9b928fa
[IIDM v1.4] Allow overwriting an existing variant (#209) (#263)
sebalaig f99900c
Remove unreached cmake code because required cmake version is 3.12 or…
sebalaig 538022a
[IIDM v1.4.1] Usage of stdcxx::optional (#267)
sebalaig 5cafded
[IIDM v1.4.1] Removal of parameters on defaulted/deleted special func…
sebalaig 8781b72
Call to direct parent's read method from xml parsers (#226) (#269)
sebalaig d749cf1
[IIDM v1.4.1] Rename stdcxx::reference_wrapper into stdcxx::Reference…
sebalaig 3ccb3a2
Refactor powsybl::iidm::util (#222) (#270)
sebalaig 2dea989
Refactoring XML read/write of a Network API (#273)
sebalaig f10cb4f
Add option to disable unit tests build (#184) (#274)
sebalaig 1667068
Pass unique_ptr as parameters by rvalue to functions (#234) (#275)
sebalaig b0aa032
Fix CI (boost not avaible on github actions) (#278)
sebalaig 1eeccab
[IIDM v1.4] Add SimpleAnonymizer (#71) (#271)
sebalaig b7f6932
[IIDM v1.4] Add AbstractTerminalTopologyVisitor (#240) (#272)
sebalaig bdc6968
fix node/breaker voltage level connect/disconnect for internal connec…
zamarrenolm 5a7aa5b
Fix CI: invoke apt-get update before installing boost (#287)
sebalaig a34a16a
[IIDM v1.4] Add ThreadLocalMultipleVariantContext (#183) (#277)
sebalaig fb284d6
Add four substations node breaker factory (#276) (#286)
sebalaig 01f6b3c
Cosmetic: fix methods order (#289)
sebalaig 1247341
Iso APIs: backport missing methods (#284)
sebalaig 9df3438
Add option to disable tools build.
gautierbureau c50b0aa
Add Substation::remove() (#283)
sebalaig a65cddc
Link extensions static libraries with iidm-static
d84e4a4
Make registerExtension public (#303)
acc3995
Add options to handle static and static runtime builds.
gautierbureau 3b81bdc
Corrections after review of handle of static/shared compilation.
gautierbureau File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,12 +4,19 @@ | |
# License, v. 2.0. If a copy of the MPL was not distributed with this | ||
# file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
# | ||
cmake_minimum_required(VERSION 3.12 FATAL_ERROR) | ||
cmake_minimum_required(VERSION 3.15 FATAL_ERROR) | ||
|
||
if (${CMAKE_VERSION} VERSION_GREATER "3.15.0") | ||
# Policy to activate a way to choose MSVC runtime. https://cmake.org/cmake/help/v3.15/policy/CMP0091.html | ||
if (POLICY CMP0091) | ||
cmake_policy(SET CMP0091 NEW) | ||
endif () | ||
endif () | ||
|
||
project(powsybl-iidm4cpp) | ||
|
||
set(IIDM_VERSION_MAJOR 1) | ||
set(IIDM_VERSION_MINOR 3) | ||
set(IIDM_VERSION_MINOR 4) | ||
set(IIDM_VERSION_PATCH 0) | ||
set(IIDM_VERSION ${IIDM_VERSION_MAJOR}.${IIDM_VERSION_MINOR}.${IIDM_VERSION_PATCH}) | ||
set(IIDM_SOVERSION ${IIDM_VERSION_MAJOR}) | ||
|
@@ -22,27 +29,54 @@ set(INSTALL_DOC_DIR share CACHE PATH "Installation directory for doxygen files") | |
|
||
option(BUILD_DOXYGEN "Enable/Disable the generation of the Doxygen." OFF) | ||
option(BUILD_EXAMPLES "Enable/Disable the compilation of the examples." OFF) | ||
option(BUILD_TESTS "Enable/Disable the compilation of unit tests." ON) | ||
option(BUILD_TOOLS "Enable/Disable the compilation of tools." ON) | ||
option(BUILD_SHARED_LIBS "Enable/disable build of shared libraries." ON) | ||
option(BUILD_STATIC_LIBS "Enable/disable build of static libraries." ON) | ||
option(BOOST_STATIC_LIBS "Use static version of boost libraries." OFF) | ||
option(MSVC_STATIC_RUNTIME_LIBRARY "Enable/disable static runtime on Windows." OFF) | ||
|
||
# Handle options compatibility | ||
if (BOOST_STATIC_LIBS AND BUILD_SHARED_LIBS) | ||
message(FATAL_ERROR "BOOST_STATIC_LIBS and BUILD_SHARED_LIBS are ON and should not be used together. | ||
BOOST_STATIC_LIBS should only be used with BUILD_STATIC_LIBS=ON and BUILD_SHARED_LIBS=OFF.") | ||
endif () | ||
|
||
if (BUILD_STATIC_LIBS AND NOT BUILD_SHARED_LIBS) | ||
set(TARGET_POSTFIX "-static") | ||
endif () | ||
|
||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") | ||
|
||
if (${CMAKE_VERSION} VERSION_LESS "3.1.0") | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --std=c++11") | ||
else () | ||
set(CMAKE_CXX_STANDARD 11) | ||
set(CMAKE_CXX_STANDARD_REQUIRED TRUE) | ||
endif () | ||
set(CMAKE_CXX_STANDARD 11) | ||
set(CMAKE_CXX_STANDARD_REQUIRED TRUE) | ||
|
||
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Werror -pedantic -Wswitch-enum") | ||
# set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_GLIBCXX_DEBUG") | ||
# set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -D_GLIBCXX_DEBUG") | ||
elseif (MSVC) | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4244 /wd4250 /wd4251 /wd4267 /wd4275") | ||
if (NOT BUILD_SHARED_LIBS AND BUILD_STATIC_LIBS) | ||
if (MSVC_STATIC_RUNTIME_LIBRARY) | ||
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This variable has been added in cmake v3.15 (https://cmake.org/cmake/help/git-stage/variable/CMAKE_MSVC_RUNTIME_LIBRARY.html). Is there an equivalent for older version? |
||
endif () | ||
else() | ||
if (MSVC_STATIC_RUNTIME_LIBRARY) | ||
message(WARNING "MSVC_STATIC_RUNTIME_LIBRARY should be used with BUILD_SHARED_LIBS=OFF and BUILD_STATIC_LIBS=ON.") | ||
endif () | ||
endif () | ||
endif () | ||
|
||
set(Boost_USE_STATIC_LIBS OFF) | ||
find_package(Boost 1.65 REQUIRED COMPONENTS date_time filesystem program_options system unit_test_framework) | ||
set(Boost_USE_STATIC_LIBS ${BOOST_STATIC_LIBS}) | ||
set(Boost_USE_STATIC_RUNTIME ${MSVC_STATIC_RUNTIME_LIBRARY}) | ||
if (BUILD_TESTS) | ||
find_package(Boost 1.65 REQUIRED COMPONENTS date_time filesystem program_options system unit_test_framework) | ||
else () | ||
find_package(Boost 1.65 REQUIRED COMPONENTS date_time filesystem program_options system) | ||
endif() | ||
find_package(LibXml2 REQUIRED) | ||
find_package(Threads REQUIRED) | ||
|
||
if (WIN32) | ||
# On windows, also force prefix to avoid conflict between import file (for shared compilation) and static file | ||
|
@@ -55,6 +89,9 @@ enable_testing() | |
|
||
set(CODE_COVERAGE FALSE CACHE BOOL "Enable code coverage") | ||
if (CODE_COVERAGE) | ||
# if code-coverage is ON, force tests build | ||
set(BUILD_TESTS ON) | ||
|
||
include(CodeCoverage) | ||
code_coverage(NAME code-coverage | ||
OUTPUT_DIR coverage | ||
|
@@ -67,9 +104,16 @@ if (BUILD_DOXYGEN) | |
endif () | ||
|
||
add_subdirectory(src) | ||
add_subdirectory(test) | ||
add_subdirectory(extensions) | ||
add_subdirectory(tools) | ||
|
||
if (BUILD_TOOLS) | ||
add_subdirectory(tools) | ||
endif () | ||
|
||
if (BUILD_TESTS) | ||
add_subdirectory(test) | ||
endif () | ||
|
||
if (BUILD_EXAMPLES) | ||
add_subdirectory(examples) | ||
endif () | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,3 +6,6 @@ | |
# | ||
|
||
add_subdirectory(example1) | ||
if (BUILD_STATIC_LIBS) | ||
add_subdirectory(example3) | ||
endif () |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# | ||
# Copyright (c) 2021, RTE (http://www.rte-france.com) | ||
# This Source Code Form is subject to the terms of the Mozilla Public | ||
# License, v. 2.0. If a copy of the MPL was not distributed with this | ||
# file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
# | ||
|
||
add_executable(example3 example3.cpp) | ||
target_link_libraries(example3 PRIVATE iidm-static ext-iidm-static) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would raise an error in that case instead of making an arbitrary choice.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done