diff --git a/src/BuildMacIntel-MacPPC.cmake b/src/BuildMacIntel-MacPPC.cmake index 22c19d0..7532732 100644 --- a/src/BuildMacIntel-MacPPC.cmake +++ b/src/BuildMacIntel-MacPPC.cmake @@ -4,8 +4,5 @@ # Author: Cas Cremers ################################################################ -message (STATUS "Building Apple Mac PPC version") -set (scythername "scyther-macppc") -add_executable (${scythername} ${Scyther_sources}) -set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fnested-functions -arch ppc") +include (BuildMacPPC.cmake) diff --git a/src/BuildMacIntel.cmake b/src/BuildMacIntel.cmake index 08c1020..f8ce918 100644 --- a/src/BuildMacIntel.cmake +++ b/src/BuildMacIntel.cmake @@ -1,6 +1,6 @@ ################################################################ # Name: BuildMacIntel.cmake -# Purpose: Build MacIntel binary on self +# Purpose: Build MacIntel binary # Author: Cas Cremers ################################################################ diff --git a/src/BuildMacPPC-MacIntel.cmake b/src/BuildMacPPC-MacIntel.cmake new file mode 100644 index 0000000..dc6a827 --- /dev/null +++ b/src/BuildMacPPC-MacIntel.cmake @@ -0,0 +1,8 @@ +################################################################ +# Name: BuildMacPPC-MacIntel.cmake +# Purpose: Build MacIntel binary on MacPPC +# Author: Cas Cremers +################################################################ + +include (BuildMacIntel.cmake) + diff --git a/src/BuildMacPPC.cmake b/src/BuildMacPPC.cmake new file mode 100644 index 0000000..8fe87a0 --- /dev/null +++ b/src/BuildMacPPC.cmake @@ -0,0 +1,11 @@ +################################################################ +# Name: BuildMacPPC.cmake +# Purpose: Build MacPPC binary +# Author: Cas Cremers +################################################################ + +message (STATUS "Building Apple Mac PPC version") +set (scythername "scyther-macppc") +add_executable (${scythername} ${Scyther_sources}) +set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fnested-functions -arch ppc") + diff --git a/src/BuildPlatform.cmake b/src/BuildPlatform.cmake index e672d51..d39876f 100644 --- a/src/BuildPlatform.cmake +++ b/src/BuildPlatform.cmake @@ -4,10 +4,14 @@ # Author: Cas Cremers ################################################################ +# Add target for Universal Binary when needed +if (APPLE) + include (UniversalBinary.cmake) +endif (APPLE) + # Retrieve Source_OS, Destination_OS (from -DTARGET) include (GetOS.cmake) -message (STATUS "Test ${Source_OS} ${Destination_OS}") # From source_os and destination_os make a new name for the build script if (Source_OS STREQUAL Destination_OS) set (BuildScriptName "Build${Source_OS}.cmake") diff --git a/src/GetOS.cmake b/src/GetOS.cmake index ec2e436..d1b023f 100644 --- a/src/GetOS.cmake +++ b/src/GetOS.cmake @@ -31,7 +31,7 @@ else (WIN32) endif (UNIX) endif (APPLE) endif (WIN32) -message (STATUS "Source platform: ${Source_OS}") +#message (STATUS "Source platform: ${Source_OS}") # Destination? If target is unset, we just take the source if (TARGETOS) @@ -39,5 +39,5 @@ if (TARGETOS) else (TARGETOS) set (Destination_OS "${Source_OS}") endif (TARGETOS) -message (STATUS "Destination platform: ${Destination_OS}") +#message (STATUS "Destination platform: ${Destination_OS}") diff --git a/src/UniversalBinary.cmake b/src/UniversalBinary.cmake new file mode 100644 index 0000000..d6fa914 --- /dev/null +++ b/src/UniversalBinary.cmake @@ -0,0 +1,39 @@ +################################################################ +# Name: UniversalBinary.cmake +# Purpose: Add target to make a Mac universal binary +# Needs pre-build mac versions first! +# Author: Cas Cremers +################################################################ + +find_program(lipoexecutable lipo) +if (lipoexecutable) + # Check whether we already have the binaries + set (requiredfiles false) + find_file (ppcfile "scyther-macppc" .) + if (ppcfile) + find_file (intelfile "scyther-macintel" .) + if (intelfile) + set (requiredfiles true) + else (intelfile) + message (FATAL_ERROR "Could not find scyther-macintel, which is required for the universal binary.") + endif (intelfile) + else (ppcfile) + message (FATAL_ERROR "Could not find scyther-macppc, which is required for the universal binary.") + endif (ppcfile) + + # Use information to proceed + if (requiredfiles) + message (STATUS "Adding target for Mac universal binary") + add_custom_target (scyther-mac + COMMAND lipo -create ${ppcfile} ${intelfile} -output scyther-mac + ) + else (requiredfiles) + message (STATUS "No universal binary possible yet. Please do the following:") + message (STATUS " cmake -DTARGETOS=MacPPC . && make") + message (STATUS " cmake -DTARGETOS=MacIntel . && make") + message (STATUS " cmake . && make scyther-mac") + endif (requiredfiles) +else (lipoexecutable) + message (FATAL_ERROR "Cannot find lipo program to create universal binaries") +endif (lipoexecutable) +