-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build: consolidate preferred compiler options (namely return-type)
- Loading branch information
Showing
5 changed files
with
48 additions
and
28 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
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,40 @@ | ||
include_guard() | ||
|
||
# DEBT: Add a parameter or option to change 'PRIVATE' default | ||
# DEBT: Strongly consider making this "target_estd_compile_options" and friends | ||
|
||
|
||
# -Wno-unused-variable want this too, remember .H files aren't compiled independently | ||
# so we have to report unused variables in unit tests fused with headers | ||
# -Wextra) not ready for this just yet, but want it | ||
|
||
|
||
macro(estd_gcc_compile_options) | ||
# Run, don't walk, do your nearest absent return type | ||
target_compile_options(${PROJECT_NAME} PRIVATE -Wall -Werror=return-type) | ||
|
||
# As per | ||
# https://stackoverflow.com/questions/31890021/mingw-too-many-sections-bug-while-compiling-huge-header-file-in-qt | ||
if(MSYS OR MINGW) | ||
message(STATUS "MSYS mode") | ||
target_compile_options(${PROJECT_NAME} PRIVATE -Wa,-mbig-obj) | ||
endif() | ||
endmacro() | ||
|
||
macro(estd_msvc_compile_options) | ||
# Kind of a blunt tool, but we're exporting so little anyway it's not too bad | ||
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) | ||
|
||
# As per https://developercommunity.visualstudio.com/t/msvc-incorrectly-defines-cplusplus/139261 | ||
# DEBT: We'll likely want this PUBLIC or INTERFACE | ||
target_compile_options(${PROJECT_NAME} PRIVATE /Zc:__cplusplus) | ||
endmacro() | ||
|
||
macro(estd_compile_options) | ||
# DEBT: Make a macro/function so we can compare "GNU-like" and include Clang, LLVM, etc. | ||
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang") | ||
estd_gcc_compile_options() | ||
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") | ||
estd_msvc_compile_options() | ||
endif() | ||
endmacro() |
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,9 +1,12 @@ | ||
include_guard() | ||
|
||
# This guy gets picked up by Catch2 tests as well as core estd itself | ||
|
||
get_filename_component(TOOLS_DIR ${CMAKE_CURRENT_LIST_DIR} ABSOLUTE) | ||
get_filename_component(ROOT_DIR ${TOOLS_DIR}/../.. ABSOLUTE) | ||
set(ESTD_DIR ${ROOT_DIR}/src) | ||
|
||
include(${TOOLS_DIR}/CPM.cmake) | ||
include(${TOOLS_DIR}/fetchcontent.cmake) | ||
include(${TOOLS_DIR}/options.cmake) | ||
include(${TOOLS_DIR}/compiler.cmake) |