Skip to content

Commit

Permalink
limit compile options to own targets so that COMPILE_WARNING_AS_ERROR…
Browse files Browse the repository at this point in the history
… can be used
  • Loading branch information
scivision committed Sep 4, 2023
1 parent a384470 commit 728a145
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 5 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ endif()

add_executable(blocktran app/main.f90 src/game.f90)
target_link_libraries(blocktran PRIVATE AI cinter menu shapes blocks keys errs sleep random)
target_compile_options(blocktran PRIVATE ${compile_opts})
set_property(TARGET blocktran PROPERTY LINKER_LANGUAGE Fortran)

add_subdirectory(src)
Expand Down
6 changes: 3 additions & 3 deletions cmake/compilers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ HAVE_RANDOM_INIT
# always do compiler options after all FindXXX and checks

if(CMAKE_Fortran_COMPILER_ID MATCHES "^Intel")
add_compile_options(
set(compile_opts
"$<$<COMPILE_LANGUAGE:Fortran>:-traceback;-warn>"
"$<$<AND:$<COMPILE_LANGUAGE:Fortran>,$<CONFIG:Debug>>:-fpe0;-debug;-check>"
)
elseif(CMAKE_Fortran_COMPILER_ID STREQUAL "GNU")
add_compile_options(-Wall -Wextra
$<$<VERSION_LESS:$<Fortran_COMPILER_VERSION>,12.0>:-Wno-maybe-uninitialized>
set(compile_opts -Wall -Wextra
"$<$<VERSION_LESS:$<Fortran_COMPILER_VERSION>,12.0>:-Wno-maybe-uninitialized>"
"$<$<AND:$<COMPILE_LANGUAGE:Fortran>,$<CONFIG:Release>>:-fno-backtrace>"
"$<$<COMPILE_LANGUAGE:Fortran>:-Werror=array-bounds;-Wconversion;-fimplicit-none>"
"$<$<AND:$<COMPILE_LANGUAGE:Fortran>,$<CONFIG:Debug>>:-fexceptions;-ffpe-trap=invalid,zero,overflow;-fcheck=all>"
Expand Down
2 changes: 0 additions & 2 deletions cmake/curses.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ else()
FetchContent_MakeAvailable(CURSES)
endif()

# Despite FetchContent, check_symbol_exists() won't work because the library isn't built at configure time.

# always true
# check_include_file("${curses_SOURCE_DIR}/curses.h" HAVE_CURSES_H)
# always true
Expand Down
2 changes: 2 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
add_compile_options("${compile_opts}")

add_library(AI OBJECT ai.f90)
target_link_libraries(AI PRIVATE shapes)

Expand Down
2 changes: 2 additions & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
add_compile_options("${compile_opts}")

add_executable(blockrand randtest.f90)
target_link_libraries(blockrand PRIVATE shapes random)
add_test(NAME random COMMAND blockrand)
Expand Down

0 comments on commit 728a145

Please sign in to comment.