Skip to content

Commit a07c0a5

Browse files
committed
Merge branch 'hotfix/3.8.5'
* hotfix/3.8.5: Version 3.8.5 Add policy to detect invalid indices Allow passing PUBLIC_DEFINITIONS to ecbuild_add_library for INTERFACE libraries
2 parents 889ab11 + 15a776d commit a07c0a5

File tree

10 files changed

+88
-8
lines changed

10 files changed

+88
-8
lines changed

‎cmake/VERSION‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.8.4
1+
3.8.5

‎cmake/ecbuild_add_library.cmake‎

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -360,11 +360,15 @@ function( ecbuild_add_library_impl )
360360
if( "${_p_TYPE}" STREQUAL LIBS )
361361
target_link_libraries( ${_PAR_TARGET} ${_p_INTF} ${deps} )
362362
ecbuild_debug("ecbuild_add_library(${_PAR_TARGET}): linking with [${deps}] ${_p_INTF}")
363-
ecbuild_debug("ecbuild_add_library(${_PAR_TARGET}): [${skipped_deps}] not found - not linking ${_p_INTF}")
363+
if( skipped_deps )
364+
ecbuild_debug("ecbuild_add_library(${_PAR_TARGET}): [${skipped_deps}] not found - not linking ${_p_INTF}")
365+
endif()
364366
else()
365367
target_include_directories( ${_PAR_TARGET} ${_p_INTF} ${deps} )
366368
ecbuild_debug("ecbuild_add_library(${_PAR_TARGET}): add [${deps}] to include_directories ${_p_INTF}")
367-
ecbuild_debug("ecbuild_add_library(${_PAR_TARGET}): [${skipped_deps}] not found - not adding to include_directories ${_p_INTF}")
369+
if( skipped_deps )
370+
ecbuild_debug("ecbuild_add_library(${_PAR_TARGET}): [${skipped_deps}] not found - not adding to include_directories ${_p_INTF}")
371+
endif()
368372
endif()
369373
endfunction()
370374

@@ -581,16 +585,16 @@ function( ecbuild_add_library_impl )
581585

582586
# add definitions to compilation
583587
if( DEFINED _PAR_PUBLIC_DEFINITIONS )
584-
target_compile_definitions(${_PAR_TARGET} PUBLIC ${_PAR_PUBLIC_DEFINITIONS})
585-
ecbuild_debug("ecbuild_add_library(${_PAR_TARGET}): adding PUBLIC definitions ${_PAR_PUBLIC_DEFINITIONS}")
588+
target_compile_definitions(${_PAR_TARGET} ${_PUBLIC_INTF} ${_PAR_PUBLIC_DEFINITIONS})
589+
ecbuild_debug("ecbuild_add_library(${_PAR_TARGET}): adding ${_PUBLIC_INTF} definitions ${_PAR_PUBLIC_DEFINITIONS}")
586590
endif()
587591
if( DEFINED _PAR_PRIVATE_DEFINITIONS )
588592
target_compile_definitions(${_PAR_TARGET} PRIVATE ${_PAR_PRIVATE_DEFINITIONS})
589593
ecbuild_debug("ecbuild_add_library(${_PAR_TARGET}): adding PRIVATE definitions ${_PAR_PRIVATE_DEFINITIONS}")
590594
endif()
591595
if( DEFINED _PAR_DEFINITIONS )
592596
if( _PAR_TYPE MATCHES "INTERFACE" )
593-
target_compile_definitions(${_PAR_TARGET} PUBLIC ${_PAR_DEFINITIONS})
597+
target_compile_definitions(${_PAR_TARGET} INTERFACE ${_PAR_DEFINITIONS})
594598
else()
595599
target_compile_definitions(${_PAR_TARGET} PRIVATE ${_PAR_DEFINITIONS})
596600
endif()

‎cmake/ecbuild_policies.cmake‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,9 @@ if( POLICY CMP0074 )
4343
cmake_policy( SET CMP0074 NEW )
4444
endif()
4545

46+
# Detect invalid indices in the ``list()`` command, new in version 3.21
47+
if( POLICY CMP0121 )
48+
cmake_policy( SET CMP0121 NEW )
49+
endif()
50+
4651
endif()

‎tests/CMakeLists.txt‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ add_subdirectory( ecbuild_add_flags )
99
add_subdirectory( find_ecbuild )
1010
add_subdirectory( project_import )
1111
add_subdirectory( ecbuild_shared_libs )
12+
add_subdirectory( interface_library )

‎tests/ecbuild_add_option/test_project/CMakeLists.txt‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ cmake_minimum_required(VERSION 3.11 FATAL_ERROR)
33
find_package( ecbuild REQUIRED )
44
project( test_add_option VERSION 0.1.0 LANGUAGES NONE )
55

6-
list(INSERT 0 CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
7-
86
ecbuild_add_option(FEATURE TEST_A) # should default to ON
97
ecbuild_add_option(FEATURE TEST_B DEFAULT ON)
108
ecbuild_add_option(FEATURE TEST_C DEFAULT OFF)

‎tests/interface_library/.gitignore‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
build_test_interface_library
2+
install_test_interface_library
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
2+
ecbuild_add_test(
3+
TARGET test_ecbuild_interface_library
4+
TYPE SCRIPT
5+
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/build-and-run.sh
6+
ENVIRONMENT CMAKE_CURRENT_SOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR} CMAKE_CURRENT_BINARY_DIR=${CMAKE_CURRENT_BINARY_DIR}
7+
)
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
5+
HERE=${CMAKE_CURRENT_BINARY_DIR:-"$( cd $( dirname "${BASH_SOURCE[0]}" ) && pwd -P )"}
6+
SOURCE=${CMAKE_CURRENT_SOURCE_DIR:-$HERE}
7+
8+
# Add ecbuild to path
9+
export PATH=$SOURCE/../../bin:$PATH
10+
echo $PATH
11+
echo $SOURCE
12+
13+
run_test() {
14+
15+
local tname=$1
16+
local exp_sts=$2
17+
shift 2
18+
19+
local bdir=$HERE/build_$tname
20+
local idir=$HERE/install_$tname
21+
local logf=$HERE/$tname.log
22+
23+
mkdir -p $bdir && cd $bdir
24+
local sts=0
25+
echo "Running test '$tname'"
26+
ecbuild --prefix=$idir -- -Wno-deprecated $* $SOURCE/test_project >$logf 2>&1 || sts=$?
27+
28+
make install
29+
30+
if [[ $sts -ne $exp_sts ]] ; then
31+
echo "Test '$tname': expected exit code $exp_sts, got $sts"
32+
cat $logf
33+
exit 1
34+
fi
35+
}
36+
37+
# --------------------- cleanup ------------------------
38+
$SOURCE/clean.sh
39+
40+
# ---------------------- tests -------------------------
41+
run_test test_interface_library 0

‎tests/interface_library/clean.sh‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
5+
HERE=${CMAKE_CURRENT_BINARY_DIR:-"$( cd $( dirname "${BASH_SOURCE[0]}" ) && pwd -P )"}
6+
7+
# --------------------- cleanup ------------------------
8+
echo "cleaning $HERE"
9+
rm -rf $HERE/build_* $HERE/*.log
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
cmake_minimum_required(VERSION 3.17 FATAL_ERROR)
2+
3+
find_package( ecbuild REQUIRED )
4+
project( test_interface_library VERSION 0.1.0 LANGUAGES C )
5+
6+
ecbuild_add_library( TARGET intfb_lib TYPE INTERFACE
7+
PUBLIC_INCLUDES
8+
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
9+
$ENV{HOME}
10+
PUBLIC_LIBS some_lib
11+
PUBLIC_DEFINITIONS MYDEF=1
12+
)
13+
ecbuild_install_project( NAME test_interface_library )

0 commit comments

Comments
 (0)