67 IF(APPLE) |
67 IF(APPLE) |
68 |
68 |
69 FIND_PACKAGE(SDL) |
69 FIND_PACKAGE(SDL) |
70 |
70 |
71 if (SDL_FOUND) |
71 if (SDL_FOUND) |
|
72 set(CMAKE_C_FLAGS "-Wall -pipe") |
|
73 set(CMAKE_C_FLAGS_RELEASE "-w -O2 -fomit-frame-pointer") |
|
74 set(CMAKE_C_FLAGS_DEBUG "-O0 -g") |
72 |
75 |
73 set(LIBRARY_OUTPUT_PATH ${EXECUTABLE_OUTPUT_PATH}) |
76 set(LIBRARY_OUTPUT_PATH ${EXECUTABLE_OUTPUT_PATH}) |
74 include_directories(${SDL_INCLUDE_DIR}) |
77 include_directories(${SDL_INCLUDE_DIR}) |
75 link_libraries(${SDL_LIBRARY}) |
78 link_libraries(${SDL_LIBRARY}) |
76 |
79 |
77 add_library (SDLmain STATIC SDLMain.m) |
80 add_library (SDLmain STATIC SDLMain.m) |
78 set(engine_sources SDLmain ${engine_sources}) |
81 set(engine_sources SDLmain ${engine_sources}) |
79 |
|
80 else (SDL_FOUND) |
82 else (SDL_FOUND) |
81 message(FATAL_ERROR "No SDL framework found!") |
83 message(FATAL_ERROR "No SDL framework found!") |
82 endif (SDL_FOUND) |
84 endif (SDL_FOUND) |
83 |
85 |
84 ENDIF(APPLE) |
86 ENDIF(APPLE) |
85 |
|
86 |
87 |
87 string(REGEX MATCH "[0-9]+\\.[0-9]+\\.[0-9]+" fpc_version "${fpc_output}") |
88 string(REGEX MATCH "[0-9]+\\.[0-9]+\\.[0-9]+" fpc_version "${fpc_output}") |
88 if (fpc_version) |
89 if (fpc_version) |
89 string(REGEX REPLACE "([0-9]+)\\.[0-9]+\\.[0-9]+" "\\1" fpc_vers_major "${fpc_version}") |
90 string(REGEX REPLACE "([0-9]+)\\.[0-9]+\\.[0-9]+" "\\1" fpc_vers_major "${fpc_version}") |
90 string(REGEX REPLACE "[0-9]+\\.([0-9])+\\.[0-9]+" "\\1" fpc_vers_minor "${fpc_version}") |
91 string(REGEX REPLACE "[0-9]+\\.([0-9])+\\.[0-9]+" "\\1" fpc_vers_minor "${fpc_version}") |
92 math(EXPR fpc_ver "${fpc_vers_major}*10000 + ${fpc_vers_minor}*100 + ${fpc_vers_patch}") |
93 math(EXPR fpc_ver "${fpc_vers_major}*10000 + ${fpc_vers_minor}*100 + ${fpc_vers_patch}") |
93 if (fpc_ver LESS "020200") |
94 if (fpc_ver LESS "020200") |
94 message("Minimum required version of FreePascal is 2.2.0") |
95 message("Minimum required version of FreePascal is 2.2.0") |
95 else (fpc_ver LESS "020200") |
96 else (fpc_ver LESS "020200") |
96 set(pascal_compiler ${fpc_executable}) |
97 set(pascal_compiler ${fpc_executable}) |
97 set(pascal_compiler_flags ${noexecstack_flags} "-B" "-FE../bin" "-Fl../bin/" "-Fl../openalbridge/" "-Cs2000000" "-vwi" "-O2" ${hwengine_project}) |
98 if( NOT CMAKE_BUILD_TYPE OR CMAKE_BUILD_TYPE MATCHES "Release") |
|
99 set(pascal_compiler_flags ${noexecstack_flags} "-B" "-FE../bin" "-Fl../bin/" "-Cs2000000" "-vwi" "-O2" "-Xs" ${hwengine_project}) |
|
100 else() |
|
101 set(pascal_compiler_flags ${noexecstack_flags} "-B" "-FE../bin" "-Fl../bin/" "-Cs2000000" "-vwi" "-O-" "-gl" ${hwengine_project}) |
|
102 endif() |
98 endif (fpc_ver LESS "020200") |
103 endif (fpc_ver LESS "020200") |
99 endif (fpc_version) |
104 endif (fpc_version) |
100 |
105 |
101 if (NOT pascal_compiler) |
106 if (NOT pascal_compiler) |
102 message(FATAL_ERROR "No Pascal compiler found!") |
107 message(FATAL_ERROR "No Pascal compiler found!") |
109 COMMAND "${pascal_compiler}" |
114 COMMAND "${pascal_compiler}" |
110 ARGS ${pascal_compiler_flags} |
115 ARGS ${pascal_compiler_flags} |
111 MAIN_DEPENDENCY ${hwengine_project} |
116 MAIN_DEPENDENCY ${hwengine_project} |
112 DEPENDS openalbridge ${engine_sources} |
117 DEPENDS openalbridge ${engine_sources} |
113 ) |
118 ) |
114 |
119 ELSE() |
115 ELSE(NOT APPLE OR NOT universal_build MATCHES "1") |
|
116 |
|
117 #these are the two dependencies for building a universal binary on Mac OS X |
120 #these are the two dependencies for building a universal binary on Mac OS X |
118 add_custom_command(OUTPUT "${EXECUTABLE_OUTPUT_PATH}/hwengine${CMAKE_EXECUTABLE_SUFFIX}.386" |
121 add_custom_command(OUTPUT "${EXECUTABLE_OUTPUT_PATH}/hwengine.386" |
119 COMMAND "ppc386" |
122 COMMAND "ppc386" |
120 ARGS ${pascal_compiler_flags} -ohwengine.386 |
123 ARGS ${pascal_compiler_flags} -ohwengine.386 |
121 MAIN_DEPENDENCY ${hwengine_project} |
124 MAIN_DEPENDENCY ${hwengine_project} |
122 DEPENDS openalbridge ${engine_sources} |
125 DEPENDS openalbridge ${engine_sources} |
123 ) |
126 ) |
124 add_custom_target(hwengine.386 ALL DEPENDS "${EXECUTABLE_OUTPUT_PATH}/hwengine${CMAKE_EXECUTABLE_SUFFIX}.386") |
127 add_custom_target(hwengine.386 ALL DEPENDS "${EXECUTABLE_OUTPUT_PATH}/hwengine.386") |
125 |
128 |
126 add_custom_command(OUTPUT "${EXECUTABLE_OUTPUT_PATH}/hwengine${CMAKE_EXECUTABLE_SUFFIX}.ppc" |
129 add_custom_command(OUTPUT "${EXECUTABLE_OUTPUT_PATH}/hwengine.ppc" |
127 COMMAND "ppcppc" |
130 COMMAND "ppcppc" |
128 ARGS ${pascal_compiler_flags} -ohwengine.ppc |
131 ARGS ${pascal_compiler_flags} -ohwengine.ppc |
129 MAIN_DEPENDENCY ${hwengine_project} |
132 MAIN_DEPENDENCY ${hwengine_project} |
130 DEPENDS openalbridge ${engine_sources} |
133 DEPENDS openalbridge ${engine_sources} |
131 ) |
134 ) |
132 add_custom_target(hwengine.ppc ALL DEPENDS "${EXECUTABLE_OUTPUT_PATH}/hwengine${CMAKE_EXECUTABLE_SUFFIX}.ppc") |
135 add_custom_target(hwengine.ppc ALL DEPENDS "${EXECUTABLE_OUTPUT_PATH}/hwengine.ppc") |
133 |
136 |
134 #this is the command that bundles the two executables into one |
137 #this is the command that bundles the two executables into one |
135 add_custom_command(OUTPUT "${EXECUTABLE_OUTPUT_PATH}/hwengine${CMAKE_EXECUTABLE_SUFFIX}" |
138 add_custom_command(OUTPUT "${EXECUTABLE_OUTPUT_PATH}/hwengine" |
136 COMMAND "lipo" |
139 COMMAND "lipo" |
137 ARGS ${EXECUTABLE_OUTPUT_PATH}/hwengine${CMAKE_EXECUTABLE_SUFFIX}.386 ${EXECUTABLE_OUTPUT_PATH}/hwengine${CMAKE_EXECUTABLE_SUFFIX}.ppc -create -output ${EXECUTABLE_OUTPUT_PATH}/hwengine${CMAKE_EXECUTABLE_SUFFIX} |
140 ARGS ${EXECUTABLE_OUTPUT_PATH}/hwengine.386 ${EXECUTABLE_OUTPUT_PATH}/hwengine.ppc -create -output ${EXECUTABLE_OUTPUT_PATH}/hwengine |
138 DEPENDS "${EXECUTABLE_OUTPUT_PATH}/hwengine${CMAKE_EXECUTABLE_SUFFIX}.386" "${EXECUTABLE_OUTPUT_PATH}/hwengine${CMAKE_EXECUTABLE_SUFFIX}.ppc" |
141 DEPENDS "${EXECUTABLE_OUTPUT_PATH}/hwengine.386" "${EXECUTABLE_OUTPUT_PATH}/hwengine.ppc" |
139 ) |
142 ) |
140 ENDIF(NOT APPLE OR NOT universal_build MATCHES "1") |
143 ENDIF() |
141 |
144 |
142 |
145 |
143 add_custom_target(hwengine ALL DEPENDS "${EXECUTABLE_OUTPUT_PATH}/hwengine${CMAKE_EXECUTABLE_SUFFIX}") |
146 add_custom_target(hwengine ALL DEPENDS "${EXECUTABLE_OUTPUT_PATH}/hwengine${CMAKE_EXECUTABLE_SUFFIX}") |
144 |
147 |
145 |
|
146 if(APPLE) |
|
147 set (target_dir ".") |
|
148 else(APPLE) |
|
149 set (target_dir "bin") |
|
150 endif(APPLE) |
|
151 |
|
152 install(PROGRAMS "${EXECUTABLE_OUTPUT_PATH}/hwengine${CMAKE_EXECUTABLE_SUFFIX}" DESTINATION ${target_dir}) |
148 install(PROGRAMS "${EXECUTABLE_OUTPUT_PATH}/hwengine${CMAKE_EXECUTABLE_SUFFIX}" DESTINATION ${target_dir}) |
153 |
149 |