2017-09-17 02:47:39 +00:00
|
|
|
function(host_compile src dst_cmd)
|
2019-10-06 15:31:26 +00:00
|
|
|
if(CMAKE_CROSSCOMPILING)
|
|
|
|
unset(link_flags)
|
2017-09-17 02:47:39 +00:00
|
|
|
|
2019-10-06 15:31:26 +00:00
|
|
|
if(CMAKE_HOST_WIN32)
|
2017-09-17 02:47:39 +00:00
|
|
|
set(dst "${dst_cmd}.exe")
|
|
|
|
|
2019-10-06 15:31:26 +00:00
|
|
|
if(CMAKE_COMPILER_IS_GNUCXX)
|
|
|
|
set(link_flags -Wl,--subsystem,console)
|
|
|
|
endif()
|
|
|
|
else()
|
2019-10-17 21:53:15 +00:00
|
|
|
set(dst ${dst_cmd})
|
2017-09-17 02:47:39 +00:00
|
|
|
endif()
|
|
|
|
|
|
|
|
# assume cc foo.c -o foo # will work on most hosts
|
2019-10-06 15:31:26 +00:00
|
|
|
add_custom_command(
|
2019-10-17 21:53:15 +00:00
|
|
|
OUTPUT ${dst}
|
2019-10-06 15:31:26 +00:00
|
|
|
COMMAND cc ${src} -o ${dst} ${link_flags}
|
2019-10-17 21:53:15 +00:00
|
|
|
DEPENDS ${src}
|
2019-10-06 15:31:26 +00:00
|
|
|
)
|
2017-09-17 02:47:39 +00:00
|
|
|
else()
|
2019-10-17 21:53:15 +00:00
|
|
|
get_filename_component(dst ${dst_cmd} NAME)
|
|
|
|
|
|
|
|
add_executable(${dst} ${src})
|
|
|
|
|
|
|
|
# this is necessary because we override main with SDL_main
|
|
|
|
target_compile_definitions(${dst} PRIVATE -Dmain=main)
|
2017-09-17 02:47:39 +00:00
|
|
|
endif()
|
|
|
|
endfunction()
|