Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 22 additions & 17 deletions cmake/defaults.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -60,22 +60,18 @@ if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
)
endif()

# This function will prevent in-source builds
function(assure_out_of_source_builds)
# make sure the user doesn't play dirty with symlinks
get_filename_component(srcdir "${CMAKE_SOURCE_DIR}" REALPATH)
get_filename_component(bindir "${CMAKE_BINARY_DIR}" REALPATH)
# make sure the user doesn't play dirty with symlinks
get_filename_component(srcdir "${CMAKE_SOURCE_DIR}" REALPATH)
get_filename_component(bindir "${CMAKE_BINARY_DIR}" REALPATH)

# disallow in-source builds
if(srcdir PATH_EQUAL bindir)
message("######################################################")
message("Warning: in-source builds are disabled")
message("Please create a separate build directory and run cmake from there")
message("######################################################")
message(FATAL_ERROR "Quitting configuration")
endif()
endfunction()
assure_out_of_source_builds()
# disallow in-source builds
if(srcdir PATH_EQUAL bindir)
message("######################################################")
message("Warning: in-source builds are disabled")
message("Please create a separate build directory and run cmake from there")
message("######################################################")
message(FATAL_ERROR "Quitting configuration")
endif()

if(ENABLE_CPPCHECK)
find_program(CPPCHECK cppcheck)
Expand Down Expand Up @@ -188,7 +184,7 @@ function(set_target_warnings target_name)
# gersemi: on
)
set(
clang_warnings
gnu_warnings
# gersemi: off
-Wall
-Wextra # reasonable and standard
Expand All @@ -213,9 +209,18 @@ function(set_target_warnings target_name)
# (ie printf)
# gersemi: on
)
set(
clang_warnings
${gnu_warnings}
# gersemi: off
-Wfunction-effects # enable function effect analysis (fea), i.e. warn if
# clang::nonallocating and clang::nonblocking attribute
# constrains are violated
# gersemi: on
)
set(
gcc_warnings
${clang_warnings}
${gnu_warnings}
# gersemi: off
-Wmisleading-indentation # warn if indentation implies blocks where blocks
# do not exist
Expand Down