Skip to content

Commit 0650800

Browse files
authored
Fix cross compiling (#2389)
Signed-off-by: Dario Binacchi <[email protected]>
1 parent 545b821 commit 0650800

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

CMakeLists.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -524,6 +524,15 @@ if (BUILD_EXAMPLES)
524524
endif (BUILD_EXAMPLES)
525525

526526
if (BUILD_CTL)
527+
if (CMAKE_CROSSCOMPILING)
528+
find_program(HOST_DROGON_CTL _drogon_ctl)
529+
if (NOT HOST_DROGON_CTL)
530+
message(FATAL_ERROR "_drogon_ctl not found on host system")
531+
endif()
532+
set(DROGON_CTL "${HOST_DROGON_CTL}")
533+
else (CMAKE_CROSSCOMPILING)
534+
set(DROGON_CTL "$<TARGET_FILE:_drogon_ctl>")
535+
endif (CMAKE_CROSSCOMPILING)
527536
add_subdirectory(drogon_ctl)
528537
endif (BUILD_CTL)
529538

drogon_ctl/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ foreach(cspFile ${SCP_LIST})
4343
get_filename_component(classname ${cspFile} NAME_WE)
4444
message(STATUS "view classname:" ${classname})
4545
add_custom_command(OUTPUT ${classname}.h ${classname}.cc
46-
COMMAND $<TARGET_FILE:_drogon_ctl>
46+
COMMAND ${DROGON_CTL}
4747
ARGS
4848
create
4949
view
@@ -63,6 +63,7 @@ if(APPLE)
6363
target_link_libraries(drogon_ctl PRIVATE resolv)
6464
endif()
6565
message(STATUS "bin:" ${INSTALL_BIN_DIR})
66+
install(TARGETS _drogon_ctl RUNTIME DESTINATION ${INSTALL_BIN_DIR})
6667
install(TARGETS drogon_ctl RUNTIME DESTINATION ${INSTALL_BIN_DIR})
6768
if(WIN32)
6869
set(CTL_FILE $<TARGET_FILE:drogon_ctl>)

examples/CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,14 @@ set(example_targets
5050
async_stream
5151
cors)
5252

53+
foreach(target ${example_targets})
54+
set_target_properties(${target} PROPERTIES
55+
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/bin)
56+
endforeach()
57+
58+
install(TARGETS ${example_targets}
59+
RUNTIME DESTINATION ${INSTALL_BIN_DIR})
60+
5361
# Add warnings for our example targets--some warnings (such as -Wunused-parameter) only appear
5462
# when the templated functions are instantiated at their point of use.
5563
if(NOT ${CMAKE_PLATFORM_NAME} STREQUAL "Windows" AND CMAKE_CXX_COMPILER_ID MATCHES GNU)

0 commit comments

Comments
 (0)