Skip to content

Commit

Permalink
Fix cmake crosscompiling (#60)
Browse files Browse the repository at this point in the history
Allow the nodesize_dbg tool to be built when crosscompiling.  Link it statically to avoid anoying library search paths then use the crosscompiling emulator to run it to generate container_node_sizes_impl during the build.

Fixes #61.
  • Loading branch information
wtsnyder authored and foonathan committed Nov 18, 2019
1 parent 5e6173c commit 06bf8d2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@ set(src
configure_file("config.hpp.in" "${CMAKE_CURRENT_BINARY_DIR}/config_impl.hpp")

# generate container_node_sizes.hpp
if(FOONATHAN_MEMORY_BUILD_TOOLS AND (NOT CMAKE_CROSSCOMPILING))
if(FOONATHAN_MEMORY_BUILD_TOOLS)
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/container_node_sizes_impl.hpp
COMMAND foonathan_memory_node_size_debugger --code --alignof "FOONATHAN_ALIGNOF(T)" ${CMAKE_CURRENT_BINARY_DIR}/container_node_sizes_impl.hpp
COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:foonathan_memory_node_size_debugger> --code --alignof "FOONATHAN_ALIGNOF(T)" ${CMAKE_CURRENT_BINARY_DIR}/container_node_sizes_impl.hpp
DEPENDS foonathan_memory_node_size_debugger
VERBATIM)
else()
Expand Down
4 changes: 4 additions & 0 deletions tool/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
# builds tools

add_executable(foonathan_memory_node_size_debugger test_types.hpp node_size_debugger.hpp node_size_debugger.cpp)
if (CMAKE_CROSSCOMPILING)
# statically link when cross compiling so emulator doesn't need library paths
set_target_properties(foonathan_memory_node_size_debugger PROPERTIES LINK_FLAGS "-static")
endif()
_foonathan_use_comp(foonathan_memory_node_size_debugger)
comp_target_features(foonathan_memory_node_size_debugger PUBLIC CPP11)
if (MSVC)
Expand Down

0 comments on commit 06bf8d2

Please sign in to comment.