Skip to content

Commit 627c7bc

Browse files
committed
Merge pull request njoy#25 in SCL/cmake from feature/fortran_options to master
* commit '4940f27875983f4cf2973707134f5138b46312a2': (21 commits) Fixed error when removing dead code Remove dead code in IntelWarn.cmake Modified IntelDiagDisable and IntelWarn deleted orphaned file Testing updated to work with WIN32 Explicit testing for compliers with 'NULL' result Alternative impl for TempArrayHeapAlloc updated testing directory Generalized Fortran Standard work and updated tests Fixed broken previous commit moved files Modified TempArrayHeapAlloc to use target property Removed unused TempArrayHeapAlloc files Created highest level testing CMakeLists.txt Added test to TempArrayHeapAlloc.cmake to prevent generating same target Update Intel-specific tests for other compilers Add tests for Backtrace, Standard2008, & FreeForm Added IntelDiagDisable and IntelWarn tests Added Fortran_IntelWarn interface Added target to disable Intel diagnostics ...
2 parents fcfc1cd + 4940f27 commit 627c7bc

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+460
-0
lines changed

FortranCompileOptions/Backtrace.cmake

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
include(Backports/IncludeGuard)
2+
include_guard(GLOBAL)
3+
4+
add_library(Fortran_Backtrace INTERFACE)
5+
add_library(FortranCompileOptions::Backtrace ALIAS Fortran_Backtrace)
6+
7+
include(FortranCompileOptions/Backtrace/Intel)
8+
include(FortranCompileOptions/Backtrace/PGI)
9+
# traceback with GNU is default
10+
# traceback with Flang is default
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
string(CONCAT generator
2+
"$<$<STREQUAL:Intel,${CMAKE_Fortran_COMPILER_ID}>:"
3+
"$<$<NOT:$<PLATFORM_ID:Windows>>:-traceback>"
4+
"$<$<PLATFORM_ID:Windows>:/traceback>>"
5+
)
6+
7+
target_compile_options(Fortran_Backtrace INTERFACE ${generator})
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
string(CONCAT generator
2+
"$<$<STREQUAL:PGI,${CMAKE_Fortran_COMPILER_ID}>:-traceback>"
3+
)
4+
5+
target_compile_options(Fortran_Backtrace INTERFACE ${generator})

FortranCompileOptions/FreeForm.cmake

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
include(Backports/IncludeGuard)
2+
include_guard(GLOBAL)
3+
4+
add_library(Fortran_FreeForm INTERFACE)
5+
add_library(FortranCompileOptions::FreeForm ALIAS Fortran_FreeForm)
6+
7+
include(FortranCompileOptions/FreeForm/Intel)
8+
include(FortranCompileOptions/FreeForm/GNU)
9+
include(FortranCompileOptions/FreeForm/Flang)
10+
include(FortranCompileOptions/FreeForm/PGI)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
string(CONCAT generator
2+
"$<$<STREQUAL:Flang,${CMAKE_Fortran_COMPILER_ID}>:-ffree-form>"
3+
)
4+
5+
target_compile_options(Fortran_FreeForm INTERFACE ${generator})
+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
string(CONCAT generator
2+
"$<$<STREQUAL:GNU,${CMAKE_Fortran_COMPILER_ID}>:-ffree-form>"
3+
)
4+
5+
target_compile_options(Fortran_FreeForm INTERFACE ${generator})
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
string(CONCAT generator
2+
"$<$<STREQUAL:Intel,${CMAKE_Fortran_COMPILER_ID}>:"
3+
"$<$<NOT:$<PLATFORM_ID:Windows>>:-free>"
4+
"$<$<PLATFORM_ID:Windows>:/free>>"
5+
)
6+
7+
target_compile_options(Fortran_FreeForm INTERFACE ${generator})
+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
string(CONCAT generator
2+
"$<$<STREQUAL:PGI,${CMAKE_Fortran_COMPILER_ID}>:-Mfree>"
3+
)
4+
5+
target_compile_options(Fortran_FreeForm INTERFACE ${generator})
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
include(Backports/IncludeGuard)
2+
include_guard(GLOBAL)
3+
4+
if( "Intel" STREQUAL "${CMAKE_Fortran_COMPILER_ID}")
5+
set(Fortran.Intel.DiagDisable "" CACHE STRING "semicolon-separated list of Intel Fortran diagnostic numbers to dissable")
6+
mark_as_advanced(Fortran.Intel.DiagDisable)
7+
endif()
8+
9+
add_library(Fortran_IntelDiagDisable INTERFACE)
10+
add_library(FortranCompileOptions::IntelDiagDisable ALIAS Fortran_IntelDiagDisable)
11+
12+
string(CONCAT generator
13+
"$<$<BOOL:$<JOIN:${Fortran.Intel.DiagDisable},>>:"
14+
"$<$<STREQUAL:Intel,${CMAKE_Fortran_COMPILER_ID}>:"
15+
"$<$<NOT:$<PLATFORM_ID:Windows>>:-diag-disable;$<JOIN:${Fortran.Intel.DiagDisable},$<COMMA>>>"
16+
"$<$<PLATFORM_ID:Windows>:/Qdiag-disable:$<JOIN:${Fortran.Intel.DiagDisable},$<COMMA>>>"
17+
">"
18+
">"
19+
)
20+
21+
target_compile_options(Fortran_IntelDiagDisable INTERFACE ${generator})

FortranCompileOptions/IntelWarn.cmake

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
include(Backports/IncludeGuard)
2+
include_guard(GLOBAL)
3+
4+
if( "Intel" STREQUAL "${CMAKE_Fortran_COMPILER_ID}")
5+
set(Fortran.Intel.Warn "" CACHE STRING "semicolon-separated list of Intel Fortran warning keyword")
6+
mark_as_advanced(Fortran.Intel.Warn)
7+
endif()
8+
9+
add_library(Fortran_IntelWarn INTERFACE)
10+
add_library(FortranCompileOptions::IntelWarn ALIAS Fortran_IntelWarn)
11+
12+
string(CONCAT generator
13+
"$<$<BOOL:$<JOIN:${Fortran.Intel.Warn},>>:"
14+
"$<$<STREQUAL:Intel,${CMAKE_Fortran_COMPILER_ID}>:"
15+
"$<$<NOT:$<PLATFORM_ID:Windows>>:-warn;$<JOIN:${Fortran.Intel.Warn},$<COMMA>>>"
16+
"$<$<PLATFORM_ID:Windows>:/warn:$<JOIN:${Fortran.Intel.Warn},$<COMMA>>>"
17+
">"
18+
">"
19+
)
20+
21+
target_compile_options(Fortran_IntelWarn INTERFACE ${generator})

FortranCompileOptions/Standard.cmake

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
include(Backports/IncludeGuard)
2+
include_guard(GLOBAL)
3+
4+
define_property(TARGET PROPERTY Fortran_Standard
5+
BRIEF_DOCS
6+
"The Fortran standard whose features are requested to build this target."
7+
FULL_DOCS
8+
"This property specifies the Fortran standard whose features are requested to
9+
build this target. For some compilers, this results in adding a flag such as
10+
-std=f2003 to the compile line. For compilers that have no notion of a
11+
standard level, such as PGI, this has no effect.
12+
13+
Supported values are 95, 2003, and 2008")
14+
15+
add_library(Fortran_Standard INTERFACE)
16+
add_library(FortranCompileOptions::Standard ALIAS Fortran_Standard)
17+
18+
include(FortranCompileOptions/Standard/Intel)
19+
include(FortranCompileOptions/Standard/GNU)
20+
include(FortranCompileOptions/Standard/PGI)
21+
# TODO: Flang -- it does not implement standards checking yet
+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
string(CONCAT generator
2+
"$<$<STREQUAL:$<TARGET_PROPERTY:Fortran_Standard>,95>:f95>"
3+
"$<$<STREQUAL:$<TARGET_PROPERTY:Fortran_Standard>,2003>:f2003>"
4+
"$<$<STREQUAL:$<TARGET_PROPERTY:Fortran_Standard>,2008>:f2008>")
5+
6+
string(CONCAT generator
7+
"$<$<STREQUAL:GNU,${CMAKE_Fortran_COMPILER_ID}>:-std=${generator}>")
8+
9+
target_compile_options(Fortran_Standard INTERFACE ${generator})
+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
string(CONCAT generator
2+
"$<$<STREQUAL:$<TARGET_PROPERTY:Fortran_Standard>,95>:f95>"
3+
"$<$<STREQUAL:$<TARGET_PROPERTY:Fortran_Standard>,2003>:f03>"
4+
"$<$<STREQUAL:$<TARGET_PROPERTY:Fortran_Standard>,2008>:f08>")
5+
6+
string(CONCAT generator
7+
"$<$<STREQUAL:Intel,${CMAKE_Fortran_COMPILER_ID}>:"
8+
"$<$<NOT:$<PLATFORM_ID:Windows>>:-stand;${generator}>"
9+
"$<$<PLATFORM_ID:Windows>:/stand:${generator}>>"
10+
)
11+
12+
target_compile_options(Fortran_Standard INTERFACE ${generator})
+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# PGI cannot check for particular standard, so we check for general standard
2+
# compliance
3+
4+
string(CONCAT generator
5+
"$<$<STREQUAL:PGI,${CMAKE_Fortran_COMPILER_ID}>:-Mstandard>"
6+
)
7+
8+
target_compile_options(Fortran_Standard INTERFACE ${generator})
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
include(Backports/IncludeGuard)
2+
include_guard(GLOBAL)
3+
4+
define_property(TARGET PROPERTY Fortran_TempArrayHeapAlloc_THRESHOLD
5+
BRIEF_DOCS
6+
"A threshold (in kilobytes) above which temporary and automatic arrays should be heap allocated"
7+
FULL_DOCS
8+
"A threshold (in kilobytes) above which temporary and automatic arrays should be heap allocated"
9+
)
10+
11+
12+
add_library(Fortran_TempArrayHeapAlloc INTERFACE)
13+
add_library(FortranCompileOptions::TempArrayHeapAlloc ALIAS Fortran_TempArrayHeapAlloc)
14+
15+
include(FortranCompileOptions/TempArrayHeapAlloc/GNU)
16+
include(FortranCompileOptions/TempArrayHeapAlloc/Flang)
17+
include(FortranCompileOptions/TempArrayHeapAlloc/Intel)
18+
include(FortranCompileOptions/TempArrayHeapAlloc/PGI)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
string(CONCAT generator
2+
"$<$<STREQUAL:Flang,${CMAKE_Fortran_COMPILER_ID}>"
3+
":$<$<BOOL:$<TARGET_PROPERTY:Fortran_TempArrayHeapAlloc_THRESHOLD>>"
4+
":-fmax-stack-var-size=$<TARGET_PROPERTY:Fortran_TempArrayHeapAlloc_THRESHOLD>000"
5+
">"
6+
">"
7+
)
8+
9+
target_compile_options(Fortran_TempArrayHeapAlloc INTERFACE ${generator})
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
string(CONCAT generator
2+
"$<$<STREQUAL:GNU,${CMAKE_Fortran_COMPILER_ID}>"
3+
":$<$<BOOL:$<TARGET_PROPERTY:Fortran_TempArrayHeapAlloc_THRESHOLD>>"
4+
":-fmax-stack-var-size=$<TARGET_PROPERTY:Fortran_TempArrayHeapAlloc_THRESHOLD>000"
5+
">"
6+
">"
7+
)
8+
9+
target_compile_options(Fortran_TempArrayHeapAlloc INTERFACE ${generator})
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
string(CONCAT generator
2+
"$<$<STREQUAL:Intel,${CMAKE_Fortran_COMPILER_ID}>"
3+
":$<$<BOOL:$<TARGET_PROPERTY:Fortran_TempArrayHeapAlloc_THRESHOLD>>"
4+
":$<$<NOT:$<PLATFORM_ID:Windows>>:-heap-arrays;$<TARGET_PROPERTY:Fortran_TempArrayHeapAlloc_THRESHOLD>>"
5+
"$<$<PLATFORM_ID:Windows>:/heap-arrays:$<TARGET_PROPERTY:Fortran_TempArrayHeapAlloc_THRESHOLD>>"
6+
">"
7+
">"
8+
)
9+
10+
target_compile_options(Fortran_TempArrayHeapAlloc INTERFACE ${generator})
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
target_compile_options(Fortran_TempArrayHeapAlloc INTERFACE
2+
"$<$<STREQUAL:PGI,${CMAKE_Fortran_COMPILER_ID}>:-Mnostack_arrays>")

FunctionExtension.cmake

+1
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ include(FunctionExtension/set_property)
1111
include(FunctionExtension/set_target_properties)
1212
include(FunctionExtension/target_sources)
1313
include(FunctionExtension/find_package)
14+
include(FunctionExtension/set_target_properties)

tests/CMakeLists.txt

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
cmake_minimum_required(VERSION 3.2.0)
2+
project(shacl_cmake LANGUAGES Fortran VERSION 1.0.0)
3+
4+
include(CTest)
5+
6+
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/..)
7+
8+
add_subdirectory(FortranCompileOptions)
9+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
include(FortranCompileOptions/Backtrace)
2+
3+
file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/use_backtrace.f90
4+
INPUT ${CMAKE_CURRENT_LIST_DIR}/use_backtrace.f90.in
5+
)
6+
7+
add_executable(use_backtrace ${CMAKE_CURRENT_BINARY_DIR}/use_backtrace.f90)
8+
target_link_libraries(use_backtrace PRIVATE FortranCompileOptions::Backtrace)
9+
10+
add_custom_target(run_use_backtrace ALL
11+
COMMAND use_backtrace
12+
)
13+
add_dependencies(run_use_backtrace use_backtrace)
14+
15+
if( WIN32 )
16+
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/terminal_output_${CMAKE_Fortran_COMPILER_ID}_win32
17+
${CMAKE_CURRENT_BINARY_DIR}/terminal_output_${CMAKE_Fortran_COMPILER_ID}_win32
18+
NEWLINE_STYLE DOS
19+
)
20+
21+
add_test(NAME run_use_backtrace
22+
COMMAND ${CMAKE_COMMAND} -E compare_files
23+
${CMAKE_CURRENT_BINARY_DIR}/terminal_output
24+
${CMAKE_CURRENT_BINARY_DIR}/terminal_output_${CMAKE_Fortran_COMPILER_ID}_win32
25+
)
26+
else()
27+
add_test(NAME run_use_backtrace
28+
COMMAND ${CMAKE_COMMAND} -E compare_files
29+
${CMAKE_CURRENT_BINARY_DIR}/terminal_output
30+
${CMAKE_CURRENT_SOURCE_DIR}/terminal_output_${CMAKE_Fortran_COMPILER_ID}
31+
)
32+
endif()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
-traceback
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/traceback
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
-traceback
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
program use_standard_semantics
2+
open(unit=42,file="terminal_output",status="unknown")
3+
write(42,*) "$<TARGET_PROPERTY:use_backtrace,COMPILE_OPTIONS>"
4+
close(42)
5+
end program
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
add_subdirectory(Backtrace)
2+
add_subdirectory(FreeForm)
3+
add_subdirectory(IntelDiagDisable)
4+
add_subdirectory(IntelWarn)
5+
add_subdirectory(Standard)
6+
add_subdirectory(TempArrayHeapAlloc)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
include(FortranCompileOptions/FreeForm)
2+
3+
file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/use_free_form.f90
4+
INPUT ${CMAKE_CURRENT_LIST_DIR}/use_free_form.f90.in
5+
)
6+
7+
add_executable(use_free_form ${CMAKE_CURRENT_BINARY_DIR}/use_free_form.f90)
8+
target_link_libraries(use_free_form PRIVATE FortranCompileOptions::FreeForm)
9+
10+
add_custom_target(run_use_free_form ALL
11+
COMMAND use_free_form
12+
)
13+
add_dependencies(run_use_free_form use_free_form)
14+
15+
if( WIN32 )
16+
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/terminal_output_${CMAKE_Fortran_COMPILER_ID}_win32
17+
${CMAKE_CURRENT_BINARY_DIR}/terminal_output_${CMAKE_Fortran_COMPILER_ID}_win32
18+
NEWLINE_STYLE DOS
19+
)
20+
21+
add_test(NAME run_use_free_form
22+
COMMAND ${CMAKE_COMMAND} -E compare_files
23+
${CMAKE_CURRENT_BINARY_DIR}/terminal_output
24+
${CMAKE_CURRENT_BINARY_DIR}/terminal_output_${CMAKE_Fortran_COMPILER_ID}_win32
25+
)
26+
else()
27+
add_test(NAME run_use_free_form
28+
COMMAND ${CMAKE_COMMAND} -E compare_files
29+
${CMAKE_CURRENT_BINARY_DIR}/terminal_output
30+
${CMAKE_CURRENT_SOURCE_DIR}/terminal_output_${CMAKE_Fortran_COMPILER_ID}
31+
)
32+
endif()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
-ffree-form
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
-ffree-form
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
-free
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/free
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
-Mfree
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
program use_standard_semantics
2+
open(unit=42,file="terminal_output",status="unknown")
3+
write(42,*) "$<TARGET_PROPERTY:use_free_form,COMPILE_OPTIONS>"
4+
close(42)
5+
end program
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
set(Fortran.Intel.DiagDisable "1138;1138" CACHE STRING "")
2+
include(FortranCompileOptions/IntelDiagDisable)
3+
4+
file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/use_intel_diag_disable.f90
5+
INPUT ${CMAKE_CURRENT_LIST_DIR}/use_intel_diag_disable.f90.in
6+
)
7+
8+
add_executable(use_intel_diag_disable ${CMAKE_CURRENT_BINARY_DIR}/use_intel_diag_disable.f90)
9+
target_link_libraries(use_intel_diag_disable PRIVATE FortranCompileOptions::IntelDiagDisable)
10+
11+
add_custom_target(run_use_intel_diag_disable ALL
12+
COMMAND use_intel_diag_disable
13+
)
14+
add_dependencies(run_use_intel_diag_disable use_intel_diag_disable)
15+
16+
if( WIN32 )
17+
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/terminal_output_${CMAKE_Fortran_COMPILER_ID}_win32
18+
${CMAKE_CURRENT_BINARY_DIR}/terminal_output_${CMAKE_Fortran_COMPILER_ID}_win32
19+
NEWLINE_STYLE DOS
20+
)
21+
22+
add_test(NAME run_use_intel_diag_disable
23+
COMMAND ${CMAKE_COMMAND} -E compare_files
24+
${CMAKE_CURRENT_BINARY_DIR}/terminal_output
25+
${CMAKE_CURRENT_BINARY_DIR}/terminal_output_${CMAKE_Fortran_COMPILER_ID}_win32
26+
)
27+
else()
28+
add_test(NAME run_use_intel_diag_disable
29+
COMMAND ${CMAKE_COMMAND} -E compare_files
30+
${CMAKE_CURRENT_BINARY_DIR}/terminal_output
31+
${CMAKE_CURRENT_SOURCE_DIR}/terminal_output_${CMAKE_Fortran_COMPILER_ID}
32+
)
33+
endif()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
-diag-disable;1138,1138
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/Qdiag-disable:1138,1138
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
program use_standard_semantics
2+
open(unit=42,file="terminal_output",status="unknown")
3+
write(42,*) "$<TARGET_PROPERTY:use_intel_diag_disable,COMPILE_OPTIONS>"
4+
close(42)
5+
end program

0 commit comments

Comments
 (0)