-
Notifications
You must be signed in to change notification settings - Fork 200
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support CMake multi-configuration generator (#149)
* Support CMake multi-configuration generator Replace `include_directories(${Boost_INCLUDE_DIRS})` with `target_include_directories(fruit PRIVATE ${Boost_INCLUDE_DIRS})`. Boost is only needed at build time, so the `PRIVATE` scope should be best. * Remove CMAKE_CXX_COMPILER_ID check `WINDOWS_EXPORT_ALL_SYMBOLS` property works only on Windows, so ‘CMAKE_CXX_COMPILER_ID‘ checks are not required. * Fix tests * Fixed a bug that a semicolon became the delimiter when `FRUIT_TEST_COMPILE_FLAGS` was expanded * Fix tests * Fix `CHECK_CXX_SOURCE_COMPILES` `CMAKE_REQUIRED_FLAGS` does not seem to inherit `CMAKE_CXX_FLAGS` etc., so I reverted to explicitly setting all flags. * Fix `CHECK_CXX_SOURCE_COMPILES` again * Fixed a bug with missing C++ standard flags CMake's multi-configuration generator support commit was missing `-std=c++11` from the `FRUIT_ADDITIONAL_COMPILE_FLAGS` variable. This caused fruit to be built with the C++ standard flags, but tests and `CHECK_CXX_SOURCE_COMPILES()` were built without the C++ standard flags. it now specifies the C++ standard option. * Fixed a bug that could not include boost headers * Set msbuild Configuration MSVC in GitHub Actions was always doing Debug builds due to the addition of CMake multi-configuration generator support. Fixed to specify `/pConfiguration=%CONFIGURATION%` in the `msbuild` command. * Fix tests * Added `FRUIT_ALLOW_MULTI_CONFIG` option * Fix wrong escape * Updated comments on `FRUIT_ALLOW_MULTI_CONFIG` option * Improved CMake multi-configuration generator tests
- Loading branch information
Showing
8 changed files
with
154 additions
and
64 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,20 +20,23 @@ jobs: | |
fail-fast: false | ||
matrix: | ||
config: | ||
- {runs_on: windows-2022, msvc_version_year: 2022, msvc_version: 17, python_path: "C:\\Python39", msvc_program_files: "C:\\Program Files", config: Debug, cxx_standard: 17} | ||
- {runs_on: windows-2022, msvc_version_year: 2022, msvc_version: 17, python_path: "C:\\Python39", msvc_program_files: "C:\\Program Files", config: Release, cxx_standard: 17} | ||
- {runs_on: windows-2022, msvc_version_year: 2022, msvc_version: 17, python_path: "C:\\Python39", msvc_program_files: "C:\\Program Files", config: Debug} | ||
- {runs_on: windows-2022, msvc_version_year: 2022, msvc_version: 17, python_path: "C:\\Python39", msvc_program_files: "C:\\Program Files", config: Release} | ||
- {runs_on: windows-2019, msvc_version_year: 2019, msvc_version: 16, python_path: "C:\\Python36", msvc_program_files: "C:\\Program Files (x86)", config: Debug, cxx_standard: 17} | ||
- {runs_on: windows-2019, msvc_version_year: 2019, msvc_version: 16, python_path: "C:\\Python36", msvc_program_files: "C:\\Program Files (x86)", config: Release, cxx_standard: 17} | ||
- {runs_on: windows-2019, msvc_version_year: 2019, msvc_version: 16, python_path: "C:\\Python36", msvc_program_files: "C:\\Program Files (x86)", config: Debug} | ||
- {runs_on: windows-2019, msvc_version_year: 2019, msvc_version: 16, python_path: "C:\\Python36", msvc_program_files: "C:\\Program Files (x86)", config: Release} | ||
- {runs_on: windows-2022, msvc_version_year: 2022, msvc_version: 17, multi_config: true, python_path: "C:\\Python39", msvc_program_files: "C:\\Program Files", config: Debug, cxx_standard: 17} | ||
- {runs_on: windows-2022, msvc_version_year: 2022, msvc_version: 17, multi_config: true, python_path: "C:\\Python39", msvc_program_files: "C:\\Program Files", config: Release, cxx_standard: 17} | ||
- {runs_on: windows-2022, msvc_version_year: 2022, msvc_version: 17, multi_config: false, python_path: "C:\\Python39", msvc_program_files: "C:\\Program Files", config: Debug, cxx_standard: 17} | ||
- {runs_on: windows-2022, msvc_version_year: 2022, msvc_version: 17, multi_config: false, python_path: "C:\\Python39", msvc_program_files: "C:\\Program Files", config: Release, cxx_standard: 17} | ||
- {runs_on: windows-2022, msvc_version_year: 2022, msvc_version: 17, multi_config: false, python_path: "C:\\Python39", msvc_program_files: "C:\\Program Files", config: Debug} | ||
- {runs_on: windows-2022, msvc_version_year: 2022, msvc_version: 17, multi_config: false, python_path: "C:\\Python39", msvc_program_files: "C:\\Program Files", config: Release} | ||
- {runs_on: windows-2019, msvc_version_year: 2019, msvc_version: 16, multi_config: false, python_path: "C:\\Python36", msvc_program_files: "C:\\Program Files (x86)", config: Debug, cxx_standard: 17} | ||
- {runs_on: windows-2019, msvc_version_year: 2019, msvc_version: 16, multi_config: false, python_path: "C:\\Python36", msvc_program_files: "C:\\Program Files (x86)", config: Release, cxx_standard: 17} | ||
- {runs_on: windows-2019, msvc_version_year: 2019, msvc_version: 16, multi_config: false, python_path: "C:\\Python36", msvc_program_files: "C:\\Program Files (x86)", config: Debug} | ||
- {runs_on: windows-2019, msvc_version_year: 2019, msvc_version: 16, multi_config: false, python_path: "C:\\Python36", msvc_program_files: "C:\\Program Files (x86)", config: Release} | ||
env: | ||
PYTHON3_PATH: ${{matrix.config.python_path}} | ||
CMAKE_GENERATOR: "Visual Studio ${{matrix.config.msvc_version}} ${{matrix.config.msvc_version_year}}" | ||
ADDITIONAL_CMAKE_ARGS: -DFRUIT_USES_BOOST=False -T host=x64 | ||
CONFIGURATION: ${{matrix.config.config}} | ||
VCVARSALL_DIR: "${{matrix.config.msvc_program_files}}\\Microsoft Visual Studio\\${{matrix.config.msvc_version_year}}\\Enterprise\\VC\\Auxiliary\\Build" | ||
FRUIT_ALLOW_MULTI_CONFIG: ${{matrix.config.multi_config}} | ||
steps: | ||
- name: Add msbuild to PATH | ||
uses: microsoft/[email protected] | ||
|
@@ -57,6 +60,10 @@ jobs: | |
if: matrix.config.msvc_version >= 16 | ||
shell: bash | ||
run: echo "ADDITIONAL_CMAKE_ARGS=$ADDITIONAL_CMAKE_ARGS -A x64" >> $GITHUB_ENV | ||
- name: set-fruit-allow-multi-config | ||
if: matrix.config.multi_config | ||
shell: bash | ||
run: echo "ADDITIONAL_CMAKE_ARGS=$ADDITIONAL_CMAKE_ARGS -DFRUIT_ALLOW_MULTI_CONFIG=True" >> $GITHUB_ENV | ||
- uses: actions/checkout@v3 | ||
- name: install | ||
shell: cmd | ||
|
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 |
---|---|---|
@@ -1,27 +1,33 @@ | ||
|
||
set(FRUIT_SOURCES | ||
memory_pool.cpp | ||
binding_normalization.cpp | ||
demangle_type_name.cpp | ||
component.cpp | ||
fixed_size_allocator.cpp | ||
injector_storage.cpp | ||
normalized_component_storage.cpp | ||
normalized_component_storage_holder.cpp | ||
semistatic_map.cpp | ||
semistatic_graph.cpp) | ||
memory_pool.cpp | ||
binding_normalization.cpp | ||
demangle_type_name.cpp | ||
component.cpp | ||
fixed_size_allocator.cpp | ||
injector_storage.cpp | ||
normalized_component_storage.cpp | ||
normalized_component_storage_holder.cpp | ||
semistatic_map.cpp | ||
semistatic_graph.cpp) | ||
|
||
if("${BUILD_SHARED_LIBS}") | ||
if(BUILD_SHARED_LIBS) | ||
add_library(fruit SHARED ${FRUIT_SOURCES}) | ||
|
||
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") | ||
set_target_properties(fruit PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS TRUE) | ||
endif() | ||
set_target_properties(fruit PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS TRUE) | ||
else() | ||
add_library(fruit STATIC ${FRUIT_SOURCES}) | ||
endif() | ||
|
||
target_include_directories(fruit PUBLIC ${FRUIT_INCLUDE_DIRS}) | ||
target_compile_options(fruit PUBLIC ${FRUIT_ADDITIONAL_COMPILE_FLAGS}) | ||
|
||
if(FRUIT_USES_BOOST) | ||
find_package(Boost REQUIRED) | ||
target_include_directories(fruit PRIVATE ${Boost_INCLUDE_DIRS}) | ||
endif() | ||
|
||
install(TARGETS fruit | ||
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" | ||
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" | ||
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}") | ||
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" | ||
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" | ||
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}") |
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
Oops, something went wrong.