-
Notifications
You must be signed in to change notification settings - Fork 168
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Restructure project to use proper CMake cross-compilation
If one were to build this project on Linux, it would fail because CMake would send Linux ld flags to the Darwin ld, which uses a completely different syntax. This required breaking out the tools into a separate CMake invocation. I have verified that the entire project builds from an empty build folder following these changes.
- Loading branch information
Showing
20 changed files
with
174 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
set(CMAKE_SYSTEM_NAME Darwin) | ||
set(CMAKE_SYSTEM_VERSION 23.0.0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
ExternalProject_Add(tools-extproj | ||
SOURCE_DIR ${CMAKE_SOURCE_DIR}/tools | ||
PREFIX ${CMAKE_BINARY_DIR}/tools | ||
BINARY_DIR ${CMAKE_BINARY_DIR}/tools | ||
CMAKE_ARGS | ||
-UCMAKE_TOOLCHAIN_FILE | ||
-DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/tools/bin | ||
-DTOOLS_FOLDER=${CMAKE_BINARY_DIR}/tools/bin | ||
BUILD_ALWAYS TRUE | ||
INSTALL_COMMAND "" | ||
BUILD_BYPRODUCTS ${tools_targets} | ||
USES_TERMINAL_CONFIGURE TRUE USES_TERMINAL_BUILD TRUE | ||
) | ||
|
||
ExternalProject_Get_Property(tools-extproj INSTALL_DIR) | ||
|
||
macro(add_imported_tool name) | ||
add_executable(host_${name} IMPORTED) | ||
set_property(TARGET host_${name} PROPERTY IMPORTED_LOCATION ${INSTALL_DIR}/bin/${name}) | ||
add_dependencies(host_${name} tools-extproj) | ||
# message(STATUS "Imported tool ${name}.") | ||
endmacro() | ||
|
||
macro(add_imported_tools) | ||
foreach(tool ${ARGN}) | ||
add_imported_tool(${tool}) | ||
endforeach() | ||
endmacro() | ||
|
||
# message(STATUS "About to add imported tools.") | ||
add_imported_tools( | ||
ctfconvert ctfdump ctfmerge xar otool ld64 unifdef migcom | ||
checksyms lipo size strings nm libtool redo_prebinding | ||
seg_addr_table seg_hack install_name_tool indr strip segedit | ||
pagestuff codesign_allocate bitcode_strip ctf_insert check_dylib | ||
cmpdylib inout vtool nmedit ld | ||
) | ||
|
||
add_executable(mig IMPORTED) | ||
set_property(TARGET mig PROPERTY IMPORTED_LOCATION ${CMAKE_SOURCE_DIR}/tools/mig/mig.sh) | ||
add_dependencies(mig host_migcom) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/bin/sh | ||
|
||
# Use this script to run the original CMake configuration process. | ||
# It automatically sets what command-line properties are needed. | ||
# You can then freely build and reconfigure from the build directory. | ||
|
||
MY_DIR=$(cd `dirname $0` && pwd) | ||
mkdir -p $MY_DIR/build | ||
cd $MY_DIR/build | ||
|
||
echo "Building in $(pwd)" | ||
cmake -G Ninja -DCMAKE_TOOLCHAIN_FILE=../cmake/toolchain.cmake .. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
add_library(host_libmacho STATIC) | ||
target_sources(host_libmacho PRIVATE | ||
add_library(libmacho STATIC) | ||
target_sources(libmacho PRIVATE | ||
arch.c | ||
) | ||
set_property(TARGET host_libmacho PROPERTY OUTPUT_NAME macho) | ||
target_include_directories(host_libmacho PRIVATE ../include ../include/foreign) | ||
set_property(TARGET libmacho PROPERTY OUTPUT_NAME macho) | ||
target_include_directories(libmacho PRIVATE ../include ../include/foreign) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.