-
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.
Project specific and target specific library type override (#60)
* SHARED LIBS: add project and target specific overrides for library type * SHARED LIBS: add tests * Changed project-wide shared libs override name and added tests
- Loading branch information
Showing
8 changed files
with
119 additions
and
0 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,7 @@ | ||
|
||
ecbuild_add_test( | ||
TARGET test_ecbuild_shared_libs | ||
TYPE SCRIPT | ||
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/build-and-run.sh | ||
ENVIRONMENT CMAKE_CURRENT_SOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR} CMAKE_CURRENT_BINARY_DIR=${CMAKE_CURRENT_BINARY_DIR} | ||
) |
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,72 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
|
||
HERE=${CMAKE_CURRENT_BINARY_DIR:-"$( cd $( dirname "${BASH_SOURCE[0]}" ) && pwd -P )"} | ||
SOURCE=${CMAKE_CURRENT_SOURCE_DIR:-$HERE} | ||
|
||
# Add ecbuild to path | ||
export PATH=$SOURCE/../../bin:$PATH | ||
echo $PATH | ||
echo $SOURCE | ||
|
||
check_lib_exists() { | ||
|
||
local libname=$1 | ||
local ext=$2 | ||
|
||
if [ ! -f $HERE/build/lib/lib${libname}.$ext ]; then | ||
echo "$HERE/build/lib/lib${libname}.$ext not found" | ||
exit 1 | ||
fi | ||
|
||
} | ||
|
||
dyn_ext="so" | ||
if [[ $(uname) == "Darwin" ]]; then | ||
dyn_ext="dylib" | ||
fi | ||
static_ext="a" | ||
|
||
logf=$HERE/test_ecbuild_shared_libs.log | ||
|
||
# enable shared libraries across project | ||
$SOURCE/clean.sh | ||
ecbuild -DENABLE_TESTS=OFF -DTEST_SHARED_LIBS_BUILD_SHARED_LIBS=OFF $SOURCE/test_project -B $HERE/build | ||
cmake --build build | ||
check_lib_exists test_shared_libs ${static_ext} | ||
check_lib_exists lib2 ${static_ext} | ||
check_lib_exists lib1 ${dyn_ext} | ||
|
||
# test that BUILD_SHARED_LIBS is overriden | ||
$SOURCE/clean.sh | ||
ecbuild -DENABLE_TESTS=OFF -DTEST_SHARED_LIBS_BUILD_SHARED_LIBS=OFF -DBUILD_SHARED_LIBS=ON $SOURCE/test_project -B $HERE/build | ||
cmake --build build | ||
check_lib_exists test_shared_libs ${static_ext} | ||
check_lib_exists lib2 ${static_ext} | ||
check_lib_exists lib1 ${dyn_ext} | ||
|
||
# test ecbuild failure for invalid argument | ||
$SOURCE/clean.sh | ||
ecbuild -DENABLE_TESTS=OFF -DTEST_SHARED_LIBS_BUILD_SHARED_LIBS=SHARED $SOURCE/test_project -B $HERE/build >$logf 2>&1 || result=$? | ||
if [ ! $result ]; then | ||
echo "ecbuild should have failed for invalid argument" | ||
cat $logf | ||
exit 1 | ||
fi | ||
|
||
# enable target specific override 1 | ||
$SOURCE/clean.sh | ||
ecbuild -DENABLE_TESTS=OFF -DECBUILD_TARGET_test_shared_libs_TYPE=SHARED -DBUILD_SHARED_LIBS=OFF $SOURCE/test_project -B $HERE/build | ||
cmake --build build | ||
check_lib_exists test_shared_libs ${dyn_ext} | ||
check_lib_exists lib2 ${static_ext} | ||
check_lib_exists lib1 ${dyn_ext} | ||
|
||
# enable target specific override 2 | ||
$SOURCE/clean.sh | ||
ecbuild -DENABLE_TESTS=OFF -DECBUILD_TARGET_test_shared_libs_TYPE=STATIC $SOURCE/test_project -B $HERE/build | ||
cmake --build build | ||
check_lib_exists test_shared_libs ${static_ext} | ||
check_lib_exists lib2 ${dyn_ext} | ||
check_lib_exists lib1 ${dyn_ext} |
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,10 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
|
||
HERE=${CMAKE_CURRENT_BINARY_DIR:-"$( cd $( dirname "${BASH_SOURCE[0]}" ) && pwd -P )"} | ||
|
||
# --------------------- cleanup ------------------------ | ||
echo "cleaning $HERE" | ||
rm -rf $HERE/build | ||
rm -f $HERE/*.log |
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,11 @@ | ||
cmake_minimum_required(VERSION 3.11 FATAL_ERROR) | ||
|
||
find_package( ecbuild REQUIRED ) | ||
project( test_shared_libs VERSION 0.1.0 LANGUAGES Fortran ) | ||
|
||
ecbuild_add_library( TARGET test_shared_libs SOURCES dummy_src.F90 ) | ||
|
||
# this should never be overriden | ||
ecbuild_add_library( TARGET lib1 TYPE SHARED SOURCES dummy_src.F90 ) | ||
|
||
ecbuild_add_library( TARGET lib2 SOURCES dummy_src.F90 ) |
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,3 @@ | ||
program main | ||
|
||
end program |