71 if (${testnoexecstack}) |
71 if (${testnoexecstack}) |
72 set (noexecstack_flags "") |
72 set (noexecstack_flags "") |
73 endif (${testnoexecstack}) |
73 endif (${testnoexecstack}) |
74 |
74 |
75 |
75 |
|
76 if(APPLE) |
|
77 string(REGEX MATCH "[pP][pP][cC]+" powerpc_build "${CMAKE_OSX_ARCHITECTURES}") |
|
78 string(REGEX MATCH "[iI]386+" i386_build "${CMAKE_OSX_ARCHITECTURES}") |
|
79 string(REGEX MATCH "[xX]86_64+" x86_64_build "${CMAKE_OSX_ARCHITECTURES}") |
|
80 |
|
81 if(powerpc_build) |
|
82 set(powerpc_build "powerpc") |
|
83 endif() |
|
84 endif(APPLE) |
|
85 |
76 #PASCAL DETECTION SECTION |
86 #PASCAL DETECTION SECTION |
77 string(REGEX MATCH "[0-9]+\\.[0-9]+\\.[0-9]+" fpc_version "${fpc_output}") |
87 string(REGEX MATCH "[0-9]+\\.[0-9]+\\.[0-9]+" fpc_version "${fpc_output}") |
78 |
88 |
79 if (fpc_version) |
89 if (fpc_version) |
80 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}") |
81 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}") |
82 string(REGEX REPLACE "[0-9]+\\.[0-9]+\\.([0-9]+)" "\\1" fpc_vers_patch "${fpc_version}") |
92 string(REGEX REPLACE "[0-9]+\\.[0-9]+\\.([0-9]+)" "\\1" fpc_vers_patch "${fpc_version}") |
83 message(STATUS "Freepascal version detected: ${fpc_vers_major}.${fpc_vers_minor}.${fpc_vers_patch}") |
93 message(STATUS "Freepascal version detected: ${fpc_vers_major}.${fpc_vers_minor}.${fpc_vers_patch}") |
84 math(EXPR fpc_ver "${fpc_vers_major}*10000 + ${fpc_vers_minor}*100 + ${fpc_vers_patch}") |
94 math(EXPR fpc_ver "${fpc_vers_major}*10000 + ${fpc_vers_minor}*100 + ${fpc_vers_patch}") |
|
95 |
85 if (fpc_ver LESS "020200") |
96 if (fpc_ver LESS "020200") |
86 message(FATAL_ERROR "Minimum required version of FreePascal is 2.2.0") |
97 message(FATAL_ERROR "Minimum required version of FreePascal is 2.2.0") |
87 else() |
98 elseif (APPLE AND i386_build AND fpc_ver LESS "020400") |
88 if (APPLE AND build_x86_64 AND fpc_ver LESS "020400") |
99 message(FATAL_ERROR "Minimum required version of FreePascal is 2.4.0 for building 64 bit applications!") |
89 message(FATAL_ERROR "Minimum required version of FreePascal is 2.4.0 for building 64 bit applications") |
|
90 endif() |
|
91 set(pascal_compiler ${fpc_executable}) |
|
92 endif () |
100 endif () |
93 endif (fpc_version) |
101 else() |
|
102 message(FATAL_ERROR "No Pascal compiler found!") |
|
103 endif () |
94 |
104 |
95 if (NOT pascal_compiler) |
105 set(pascal_compiler ${fpc_executable}) |
96 message(FATAL_ERROR "No Pascal compiler found!") |
|
97 endif (NOT pascal_compiler) |
|
98 |
|
99 |
|
100 set(pascal_compiler_flags ${noexecstack_flags} ${pascal_compiler_flags_cmn} ${hwengine_project}) |
106 set(pascal_compiler_flags ${noexecstack_flags} ${pascal_compiler_flags_cmn} ${hwengine_project}) |
101 |
|
102 if(LOWRES) |
|
103 set(pascal_compiler_flags "-dLOWRES" ${pascal_compiler_flags} ${hwengine_project}) |
|
104 endif(LOWRES) |
|
105 |
107 |
106 |
108 |
107 #DEPENDECIES AND EXECUTABLES SECTION |
109 #DEPENDECIES AND EXECUTABLES SECTION |
108 IF(APPLE) |
110 IF(APPLE) |
109 #let's build sdlmain, which is absent from the framework |
111 #let's build sdlmain, which is absent from the framework |
112 set(LIBRARY_OUTPUT_PATH ${EXECUTABLE_OUTPUT_PATH}) |
114 set(LIBRARY_OUTPUT_PATH ${EXECUTABLE_OUTPUT_PATH}) |
113 include_directories(${SDL_INCLUDE_DIR}) |
115 include_directories(${SDL_INCLUDE_DIR}) |
114 link_libraries(${SDL_LIBRARY}) |
116 link_libraries(${SDL_LIBRARY}) |
115 |
117 |
116 add_library (SDLmain STATIC SDLMain.m) |
118 add_library (SDLmain STATIC SDLMain.m) |
117 set(engine_sources SDLmain ${engine_sources}) |
|
118 ENDIF(APPLE) |
119 ENDIF(APPLE) |
119 |
120 |
120 IF(NOT APPLE) |
121 IF(NOT APPLE) |
121 #here is the standard command for any system |
122 #here is the standard command for any system |
122 add_custom_command(OUTPUT "${EXECUTABLE_OUTPUT_PATH}/hwengine${CMAKE_EXECUTABLE_SUFFIX}" |
123 add_custom_command(OUTPUT "${EXECUTABLE_OUTPUT_PATH}/hwengine${CMAKE_EXECUTABLE_SUFFIX}" |
125 MAIN_DEPENDENCY ${hwengine_project} |
126 MAIN_DEPENDENCY ${hwengine_project} |
126 DEPENDS ${engine_sources} |
127 DEPENDS ${engine_sources} |
127 ) |
128 ) |
128 ELSE() |
129 ELSE() |
129 #these are the dependencies for building a universal binary on Mac OS X |
130 #these are the dependencies for building a universal binary on Mac OS X |
130 if(build_ppc) |
131 foreach (build_arch ${powerpc_build} ${i386_build} ${x86_64_build}) |
131 set(lipo_args_list "${EXECUTABLE_OUTPUT_PATH}/hwengine.ppc" ${lipo_args_list}) |
132 set(lipo_args_list "${EXECUTABLE_OUTPUT_PATH}/hwengine.${build_arch}" ${lipo_args_list}) |
132 endif() |
133 add_custom_command(OUTPUT "${EXECUTABLE_OUTPUT_PATH}/hwengine.${build_arch}" |
133 if(build_i386) |
134 COMMAND "${pascal_compiler}" |
134 set(lipo_args_list "${EXECUTABLE_OUTPUT_PATH}/hwengine.386" ${lipo_args_list}) |
135 ARGS ${pascal_compiler_flags} -ohwengine.${build_arch} -P${build_arch} |
135 endif() |
136 MAIN_DEPENDENCY ${hwengine_project} |
136 if(build_x86_64) |
137 DEPENDS ${engine_sources} |
137 set(lipo_args_list "${EXECUTABLE_OUTPUT_PATH}/hwengine.x64" ${lipo_args_list}) |
138 ) |
138 endif() |
139 add_custom_target(hwengine.${build_arch} ALL DEPENDS "${EXECUTABLE_OUTPUT_PATH}/hwengine.${build_arch}") |
139 |
140 endforeach() |
140 add_custom_command(OUTPUT "${EXECUTABLE_OUTPUT_PATH}/hwengine.386" |
|
141 COMMAND "${pascal_compiler}" |
|
142 ARGS ${pascal_compiler_flags} -ohwengine.386 -Pi386 |
|
143 MAIN_DEPENDENCY ${hwengine_project} |
|
144 DEPENDS ${engine_sources} |
|
145 ) |
|
146 add_custom_target(hwengine.386 ALL DEPENDS "${EXECUTABLE_OUTPUT_PATH}/hwengine.386") |
|
147 |
|
148 add_custom_command(OUTPUT "${EXECUTABLE_OUTPUT_PATH}/hwengine.ppc" |
|
149 COMMAND "${pascal_compiler}" |
|
150 ARGS ${pascal_compiler_flags} -ohwengine.ppc -Ppowerpc |
|
151 MAIN_DEPENDENCY ${hwengine_project} |
|
152 DEPENDS ${engine_sources} |
|
153 ) |
|
154 add_custom_target(hwengine.ppc ALL DEPENDS "${EXECUTABLE_OUTPUT_PATH}/hwengine.ppc") |
|
155 |
|
156 add_custom_command(OUTPUT "${EXECUTABLE_OUTPUT_PATH}/hwengine.x64" |
|
157 COMMAND "${pascal_compiler}" |
|
158 ARGS ${pascal_compiler_flags} -ohwengine.x64 -Px86_64 |
|
159 MAIN_DEPENDENCY ${hwengine_project} |
|
160 DEPENDS ${engine_sources} |
|
161 ) |
|
162 add_custom_target(hwengine.x64 ALL DEPENDS "${EXECUTABLE_OUTPUT_PATH}/hwengine.x64") |
|
163 |
141 |
164 add_custom_command(OUTPUT "${EXECUTABLE_OUTPUT_PATH}/hwengine" |
142 add_custom_command(OUTPUT "${EXECUTABLE_OUTPUT_PATH}/hwengine" |
165 COMMAND "lipo" |
143 COMMAND "lipo" |
166 ARGS ${lipo_args_list} -create -output ${EXECUTABLE_OUTPUT_PATH}/hwengine |
144 ARGS ${lipo_args_list} -create -output ${EXECUTABLE_OUTPUT_PATH}/hwengine |
167 DEPENDS ${lipo_args_list} |
145 DEPENDS ${lipo_args_list} |