Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ target_include_directories(${BTCPP_LIBRARY}
${BTCPP_EXTRA_INCLUDE_DIRS}
)

target_compile_definitions(${BTCPP_LIBRARY} PUBLIC BTCPP_LIBRARY_VERSION="${CMAKE_PROJECT_VERSION}")
target_compile_definitions(${BTCPP_LIBRARY} PUBLIC BTCPP_LIBRARY_VERSION="${PROJECT_VERSION}")

target_compile_features(${BTCPP_LIBRARY} PUBLIC cxx_std_17)

Expand Down
9 changes: 9 additions & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,15 @@ else()

endif()

add_test(
NAME cmake_subproject_version
COMMAND ${CMAKE_COMMAND}
-S ${CMAKE_CURRENT_SOURCE_DIR}/cmake/subproject_version
-B ${CMAKE_CURRENT_BINARY_DIR}/cmake/subproject_version
"-DBTCPP_SOURCE_DIR=${PROJECT_SOURCE_DIR}"
"-DBTCPP_EXPECTED_VERSION=${PROJECT_VERSION}"
)

target_include_directories(behaviortree_cpp_test PRIVATE include)
target_link_libraries(behaviortree_cpp_test ${BTCPP_LIBRARY} bt_sample_nodes)
if(MSVC)
Expand Down
25 changes: 25 additions & 0 deletions tests/cmake/subproject_version/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
cmake_minimum_required(VERSION 3.16.3)

project(btcpp_parent VERSION 9.8.7 LANGUAGES C CXX)

if(NOT BTCPP_SOURCE_DIR OR NOT BTCPP_EXPECTED_VERSION)
message(FATAL_ERROR "BTCPP_SOURCE_DIR and BTCPP_EXPECTED_VERSION are required")
endif()

set(BUILD_TESTING OFF CACHE BOOL "" FORCE)
set(BTCPP_BUILD_TOOLS OFF CACHE BOOL "" FORCE)
set(BTCPP_EXAMPLES OFF CACHE BOOL "" FORCE)
set(BTCPP_GROOT_INTERFACE OFF CACHE BOOL "" FORCE)
set(BTCPP_SQLITE_LOGGING OFF CACHE BOOL "" FORCE)
set(CMAKE_DISABLE_FIND_PACKAGE_ament_cmake TRUE CACHE BOOL "" FORCE)

add_subdirectory("${BTCPP_SOURCE_DIR}" behaviortree_cpp)

get_target_property(btcpp_compile_definitions behaviortree_cpp COMPILE_DEFINITIONS)
set(expected_definition "BTCPP_LIBRARY_VERSION=\"${BTCPP_EXPECTED_VERSION}\"")
list(FIND btcpp_compile_definitions "${expected_definition}" expected_version_index)

if(expected_version_index EQUAL -1)
message(FATAL_ERROR
"Expected ${expected_definition}, got: ${btcpp_compile_definitions}")
endif()
Loading