Skip to content

Commit

Permalink
foonathan build fixes & upgrade to 0.7-3
Browse files Browse the repository at this point in the history
  • Loading branch information
maloel committed Oct 21, 2023
1 parent ecd987e commit 1cbd1f0
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 34 deletions.
35 changes: 35 additions & 0 deletions CMake/Findfoonathan_memory.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@

# This is a dummy file, just so CMake does not complain:

# CMake Error at build/third-party/fastdds/CMakeLists.txt:239 (find_package):
# By not providing "Findfoonathan_memory.cmake" in CMAKE_MODULE_PATH this
# project has asked CMake to find a package configuration file provided by
# "foonathan_memory", but CMake did not find one.
#
# Could not find a package configuration file provided by "foonathan_memory"
# with any of the following names:
#
# foonathan_memoryConfig.cmake
# foonathan_memory-config.cmake
#
# Add the installation prefix of "foonathan_memory" to CMAKE_PREFIX_PATH or
# set "foonathan_memory_DIR" to a directory containing one of the above
# files. If "foonathan_memory" provides a separate development package or
# SDK, be sure it has been installed.

# FastDDS requires foonathan_memory and will not find it if we do not provide this
# file.
#
# Since all the variables should already be set by external_foonathan_memory.cmake,
# we don't really do anything.

# This may not be the proper way to do this. But it works...


#message( "In Findfoonathan_memory.cmake" )


#find_package( PkgConfig )
#pkg_check_modules( foonathan_memory QUIET foonathan_memory )


4 changes: 2 additions & 2 deletions CMake/external_fastdds.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@ function(get_fastdds)
mark_as_advanced(FETCHCONTENT_UPDATES_DISCONNECTED_FASTDDS)

# place FastDDS project with other 3rd-party projects
set_target_properties(fastcdr fastrtps PROPERTIES
set_target_properties(fastcdr fastrtps foonathan_memory PROPERTIES
FOLDER "ExternalProjectTargets/fastdds")

list(POP_BACK CMAKE_MESSAGE_INDENT) # Unindent outputs

add_library(dds INTERFACE)
target_link_libraries(dds INTERFACE fastcdr fastrtps)
target_link_libraries( dds INTERFACE fastcdr fastrtps )

add_definitions(-DBUILD_WITH_DDS)

Expand Down
38 changes: 6 additions & 32 deletions CMake/external_foonathan_memory.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ list(APPEND CMAKE_MESSAGE_INDENT " ")
FetchContent_Declare(
foonathan_memory
GIT_REPOSITORY https://github.com/foonathan/memory.git
GIT_TAG "v0.7-2"
GIT_TAG "v0.7-3"
GIT_SHALLOW ON # No history needed
SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR}/third-party/foonathan_memory
)
Expand All @@ -22,7 +22,7 @@ FetchContent_Declare(
set(FOONATHAN_MEMORY_BUILD_VARS -DBUILD_SHARED_LIBS=OFF # explicit set static lib
-DFOONATHAN_MEMORY_BUILD_EXAMPLES=OFF
-DFOONATHAN_MEMORY_BUILD_TESTS=OFF
-DFOONATHAN_MEMORY_BUILD_TOOLS=ON) # this tool is needed during configure time only, FastDDS recommend turning it ON.
-DFOONATHAN_MEMORY_BUILD_TOOLS=OFF)

# Align STATIC CRT definitions with LRS
if(BUILD_WITH_STATIC_CRT)
Expand All @@ -45,39 +45,13 @@ mark_as_advanced(FETCHCONTENT_SOURCE_DIR_FOONATHAN_MEMORY)
mark_as_advanced(FETCHCONTENT_UPDATES_DISCONNECTED_FOONATHAN_MEMORY)


# Configure stage
execute_process(COMMAND "${CMAKE_COMMAND}" -G "${CMAKE_GENERATOR}" -DCMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_BINARY_DIR}/fastdds/fastdds_install
${FOONATHAN_MEMORY_BUILD_VARS}
.
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/third-party/foonathan_memory"
OUTPUT_QUIET
RESULT_VARIABLE configure_ret
)
add_subdirectory( "${foonathan_memory_SOURCE_DIR}" )

# Build and install Debug version
execute_process(COMMAND "${CMAKE_COMMAND}" --build . --config Debug --target install
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/third-party/foonathan_memory"
OUTPUT_QUIET
RESULT_VARIABLE debug_build_ret
)

# Build and install RelWithDeb version
execute_process(COMMAND "${CMAKE_COMMAND}" --build . --config RelWithDebInfo --target install
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/third-party/foonathan_memory"
OUTPUT_QUIET
RESULT_VARIABLE rel_with_deb_info_build_ret
)

# Build and install Release version
execute_process(COMMAND "${CMAKE_COMMAND}" --build . --config Release --target install
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/third-party/foonathan_memory"
OUTPUT_QUIET
RESULT_VARIABLE release_build_ret
)
# Without this line, everything seems to work but find_package() will give:
# Found foonathan_memory: foonathan_memory_DIR-NOTFOUND
set( foonathan_memory_DIR "${foonathan_memory_SOURCE_DIR}" )

if(configure_ret OR debug_build_ret OR release_build_ret OR rel_with_deb_info_build_ret)
message( FATAL_ERROR "Failed to build foonathan_memory")
endif()

list(POP_BACK CMAKE_MESSAGE_INDENT)
message(CHECK_PASS "Done")

0 comments on commit 1cbd1f0

Please sign in to comment.