File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -96,11 +96,20 @@ configure_file(
9696# When cross-compiling, build it natively so it can run on the build host.
9797if (CMAKE_CROSSCOMPILING )
9898 include (ExternalProject )
99+ set (_c2str_host_src_dir "${CMAKE_CURRENT_BINARY_DIR} /c2str-host-src" )
99100 set (_c2str_host_build_dir "${CMAKE_CURRENT_BINARY_DIR} /c2str-host-build" )
101+ # Generate the host-tool project into the build tree so it works whether
102+ # minicc is used directly or fetched via FetchContent/ExternalProject.
103+ string (REPLACE "\\ " "/" _conftest_src "${CMAKE_CURRENT_SOURCE_DIR} /conftest.c" )
104+ file (WRITE "${_c2str_host_src_dir} /CMakeLists.txt"
105+ "cmake_minimum_required(VERSION 3.20)\n "
106+ "project(minicc_c2str_host C)\n "
107+ "add_executable(minicc-c2str \" ${_conftest_src} \" )\n "
108+ "target_compile_definitions(minicc-c2str PRIVATE C2STR=1)\n "
109+ )
100110 ExternalProject_Add (minicc-c2str-host
101- SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR} /cmake/c2str-host "
111+ SOURCE_DIR "${_c2str_host_src_dir} "
102112 BINARY_DIR "${_c2str_host_build_dir} "
103- CMAKE_ARGS "-DC2STR_SOURCE=${CMAKE_CURRENT_SOURCE_DIR} /conftest.c"
104113 INSTALL_COMMAND ""
105114 BUILD_BYPRODUCTS "${_c2str_host_build_dir} /minicc-c2str"
106115 )
You can’t perform that action at this time.
0 commit comments