-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Honour build-type specific flags in source flag override
- Loading branch information
Showing
9 changed files
with
123 additions
and
13 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
set(_dir ${CMAKE_CURRENT_BINARY_DIR}) | ||
configure_file(run-test.sh.in ${_dir}/run-test.sh @ONLY) | ||
configure_file(test_ecbuild_source_flags.cmake ${_dir}/CMakeLists.txt COPYONLY) | ||
configure_file(emptyfile.c ${_dir}/emptyfile.c COPYONLY) | ||
configure_file(emptyfile.cxx ${_dir}/emptyfile.cxx COPYONLY) | ||
configure_file(emptyfile.F90 ${_dir}/emptyfile.F90 COPYONLY) | ||
|
||
ecbuild_add_test( | ||
TARGET test_ecbuild_source_flags | ||
TYPE SCRIPT | ||
COMMAND run-test.sh | ||
) |
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 @@ | ||
! An empty file |
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 @@ | ||
// An empty file |
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 @@ | ||
// An empty file |
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,14 @@ | ||
{ | ||
"*" : [ "=", "-g" ], | ||
"*.F90" : [ "+", "-fortran_only_flag" ], | ||
"*.c" : [ "+", "-fPIC" ], | ||
"*.cxx" : [ "+", "-fPIC" ], | ||
"debug": { | ||
"*.c": [ "+", "-O0" ], | ||
"*.cxx": [ "+", "-O0" ] | ||
}, | ||
"bit": { | ||
"*.c": [ "+", "-O2" ], | ||
"*.cxx": [ "+", "-O2" ] | ||
} | ||
} |
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,22 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
|
||
HERE="$( cd $( dirname "${BASH_SOURCE[0]}" ) && pwd -P )" | ||
|
||
cd $HERE | ||
|
||
rm -rf build # cleanup | ||
mkdir build | ||
cd build | ||
|
||
cmake -DCMAKE_MODULE_PATH=@ECBUILD_MACROS_DIR@ -DECBUILD_LOG_LEVEL=DEBUG -DCMAKE_BUILD_TYPE=BIT -DECBUILD_SOURCE_FLAGS=@CMAKE_CURRENT_SOURCE_DIR@/flags-sourceflags.json .. | ||
|
||
cd .. | ||
|
||
rm -rf build # cleanup | ||
mkdir build | ||
cd build | ||
|
||
cmake -DCMAKE_MODULE_PATH=@ECBUILD_MACROS_DIR@ -DECBUILD_LOG_LEVEL=DEBUG -DCMAKE_BUILD_TYPE=DEBUG -DECBUILD_SOURCE_FLAGS=@CMAKE_CURRENT_SOURCE_DIR@/flags-sourceflags.json .. | ||
|
43 changes: 43 additions & 0 deletions
43
tests/ecbuild_source_flags/test_ecbuild_source_flags.cmake
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,43 @@ | ||
cmake_minimum_required( VERSION 3.12 FATAL_ERROR ) | ||
|
||
find_package( ecbuild 3.6 REQUIRED ) | ||
|
||
project(SourceFlags VERSION 1.0 LANGUAGES C CXX Fortran) | ||
|
||
ecbuild_add_library( | ||
TARGET overrideflags | ||
SOURCES emptyfile.c emptyfile.cxx emptyfile.F90 | ||
) | ||
|
||
get_property( _flags SOURCE emptyfile.c PROPERTY COMPILE_FLAGS ) | ||
if( CMAKE_BUILD_TYPE MATCHES BIT ) | ||
if( NOT ${_flags} MATCHES "-g -fPIC -O2" ) | ||
message(${_flags}) | ||
message(FATAL_ERROR "Incorrect BIT flags for emptyfile.c") | ||
endif() | ||
elseif( CMAKE_BUILD_TYPE MATCHES DEBUG ) | ||
if( NOT ${_flags} MATCHES "-g -fPIC -O0" ) | ||
message(${_flags}) | ||
message(FATAL_ERROR "Incorrect DEBUG flags for emptyfile.c") | ||
endif() | ||
endif() | ||
|
||
get_property( _flags SOURCE emptyfile.cxx PROPERTY COMPILE_FLAGS ) | ||
if( CMAKE_BUILD_TYPE MATCHES BIT ) | ||
if( NOT ${_flags} MATCHES "-g -fPIC -O2" ) | ||
message(${_flags}) | ||
message(FATAL_ERROR "Incorrect BIT flags for emptyfile.cxx") | ||
endif() | ||
elseif( CMAKE_BUILD_TYPE MATCHES DEBUG ) | ||
if( NOT ${_flags} MATCHES "-g -fPIC -O0" ) | ||
message(${_flags}) | ||
message(FATAL_ERROR "Incorrect DEBUG flags for emptyfile.cxx") | ||
endif() | ||
endif() | ||
|
||
get_property( _flags SOURCE emptyfile.F90 PROPERTY COMPILE_FLAGS ) | ||
if( NOT ${_flags} MATCHES "-g -fortran_only_flag" ) | ||
message(${_flags}) | ||
message(FATAL_ERROR "Incorrect flags for emptyfile.F90") | ||
endif() | ||
|