hedgewars/CMakeLists.txt
changeset 8093 2286a39140da
parent 8090 38d9cc60b14c
child 8096 453917e94e55
child 8146 1fba650c2aa4
equal deleted inserted replaced
8091:e0a76056a633 8093:2286a39140da
   106     set(fpc_executable ${FPC})
   106     set(fpc_executable ${FPC})
   107 ELSE()
   107 ELSE()
   108     find_program(fpc_executable fpc)
   108     find_program(fpc_executable fpc)
   109 ENDIF()
   109 ENDIF()
   110 
   110 
   111 if(fpc_executable)
   111 message(STATUS "Check for working FPC compiler: ${fpc_executable}")
   112     execute_process(COMMAND ${fpc_executable} -iV OUTPUT_VARIABLE fpc_output)
   112 execute_process(COMMAND ${fpc_executable} -iV OUTPUT_VARIABLE fpc_output ERROR_VARIABLE fpc_error)
   113 endif(fpc_executable)
   113 if(fpc_error)
       
   114     message(STATUS "Check for working FPC compiler: ${fpc_executable} -- broken")
       
   115 else(fpc_error)
       
   116     message(STATUS "Check for working FPC compiler: ${fpc_executable} -- works")
       
   117 endif(fpc_error)
   114 
   118 
   115 string(REGEX MATCH "[0-9]+\\.[0-9]+\\.[0-9]+" fpc_version "${fpc_output}")
   119 string(REGEX MATCH "[0-9]+\\.[0-9]+\\.[0-9]+" fpc_version "${fpc_output}")
   116 if(fpc_version)
   120 if(fpc_version)
   117     string(REGEX REPLACE "([0-9]+)\\.[0-9]+\\.[0-9]+" "\\1" fpc_vers_major "${fpc_version}")
   121     string(REGEX REPLACE "([0-9]+)\\.[0-9]+\\.[0-9]+" "\\1" fpc_vers_major "${fpc_version}")
   118     string(REGEX REPLACE "[0-9]+\\.([0-9]+)\\.[0-9]+" "\\1" fpc_vers_minor "${fpc_version}")
   122     string(REGEX REPLACE "[0-9]+\\.([0-9]+)\\.[0-9]+" "\\1" fpc_vers_minor "${fpc_version}")
   127     endif()
   131     endif()
   128 else()
   132 else()
   129     message(FATAL_ERROR "No FreePascal compiler found!")
   133     message(FATAL_ERROR "No FreePascal compiler found!")
   130 endif()
   134 endif()
   131 
   135 
       
   136 message(STATUS "Checking whether linker supports noexecstack flag")
   132 set(noexecstack_flags "-k-z" "-knoexecstack")
   137 set(noexecstack_flags "-k-z" "-knoexecstack")
   133 file(WRITE ${EXECUTABLE_OUTPUT_PATH}/checkstack.pas "begin end.")
   138 file(WRITE ${EXECUTABLE_OUTPUT_PATH}/checkstack.pas "begin end.")
   134 
   139 
   135 execute_process(COMMAND ${fpc_executable} ${noexecstack_flags} checkstack.pas
   140 execute_process(COMMAND ${fpc_executable} ${noexecstack_flags} checkstack.pas
   136     WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}
   141     WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}
   137     RESULT_VARIABLE testnoexecstack
   142     RESULT_VARIABLE testnoexecstack
   138     OUTPUT_QUIET
   143     OUTPUT_QUIET ERROR_QUIET
   139     )
   144     )
   140 
   145 
   141 if(${testnoexecstack})
   146 if(${testnoexecstack})
   142     set (noexecstack_flags "")
   147     set (noexecstack_flags "")
       
   148     message(STATUS "Checking whether linker supports noexecstack flag -- no")
       
   149 else(${testnoexecstack})
       
   150     message(STATUS "Checking whether linker supports noexecstack flag -- yes")
   143 endif(${testnoexecstack})
   151 endif(${testnoexecstack})
   144 
   152 
   145 #DEPENDECIES AND EXECUTABLES SECTION
   153 #DEPENDECIES AND EXECUTABLES SECTION
   146 if(APPLE)
   154 if(APPLE)
   147     string(REGEX MATCH "[pP][pP][cC]+" powerpc_build "${CMAKE_OSX_ARCHITECTURES}")
   155     string(REGEX MATCH "[pP][pP][cC]+" powerpc_build "${CMAKE_OSX_ARCHITECTURES}")
   180         set(pascal_flags "-dPNG_SCREENSHOTS" ${pascal_flags})
   188         set(pascal_flags "-dPNG_SCREENSHOTS" ${pascal_flags})
   181         if(APPLE)  # fpc png unit doesn't pull the library (see bug 21833)
   189         if(APPLE)  # fpc png unit doesn't pull the library (see bug 21833)
   182             set(pascal_flags "-k${PNG_LIBRARY}" ${pascal_flags})
   190             set(pascal_flags "-k${PNG_LIBRARY}" ${pascal_flags})
   183         endif()
   191         endif()
   184     else()
   192     else()
   185         message(STATUS "Screenshots will be in BMP format because libpng was not found")
   193         message(WARNING "Screenshots will be in BMP format because libpng was not found")
   186     endif()
   194     endif()
   187 else()
   195 else()
   188     message(STATUS "Screenshots will be in BMP format per user request")
   196     message(STATUS "Screenshots will be in BMP format per user request")
   189 endif()
   197 endif()
   190 
       
   191 
   198 
   192 
   199 
   193 #this command is a workaround to some inlining issues present in older FreePascal versions and fixed in 2.6
   200 #this command is a workaround to some inlining issues present in older FreePascal versions and fixed in 2.6
   194 if(fpc_version LESS "020600")
   201 if(fpc_version LESS "020600")
   195     #under some configurations CMAKE_BUILD_TOOL fails to pass on the jobserver, breaking parallel compilation
   202     #under some configurations CMAKE_BUILD_TOOL fails to pass on the jobserver, breaking parallel compilation
   222         ELSE()
   229         ELSE()
   223             add_library(avwrapper STATIC avwrapper.c)
   230             add_library(avwrapper STATIC avwrapper.c)
   224             set(pascal_flags "-k${FFMPEG_LIBAVCODEC}" "-k${FFMPEG_LIBAVFORMAT}" "-k${FFMPEG_LIBAVUTIL}" ${pascal_flags})
   231             set(pascal_flags "-k${FFMPEG_LIBAVCODEC}" "-k${FFMPEG_LIBAVFORMAT}" "-k${FFMPEG_LIBAVUTIL}" ${pascal_flags})
   225         ENDIF()
   232         ENDIF()
   226     else()
   233     else()
   227         message(STATUS "Could NOT find FFMPEG/LibAV, video recording will be disabled")
   234         message(WARNING "Could NOT find FFMPEG/LibAV, video recording will be disabled")
   228     endif()
   235     endif()
   229 else()
   236 else()
   230     message(STATUS "Video recording disabled by user")
   237     message(STATUS "Video recording disabled by user")
   231 endif()
   238 endif()
   232 
   239