apply the new macro add_flag_* to set pascal flags, apply add_definitions where appropriate, small cleanup
--- a/CMakeLists.txt Tue Mar 19 09:53:12 2013 +0100
+++ b/CMakeLists.txt Tue Mar 19 10:34:46 2013 +0100
@@ -16,7 +16,7 @@
endforeach()
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake_modules")
-
+include(${CMAKE_MODULE_PATH}/utils.cmake)
#possible cmake configuration
option(NOSERVER "Disable gameServer build (off)]" OFF)
@@ -161,7 +161,7 @@
set(DYLIB_SMPEG "-dylib_file @loader_path/Frameworks/smpeg.framework/Versions/A/smpeg:${SDLMIXER_LIBRARY}/Versions/A/Frameworks/smpeg.framework/Versions/A/smpeg")
set(DYLIB_MIKMOD "-dylib_file @loader_path/Frameworks/mikmod.framework/Versions/A/mikmod:${SDLMIXER_LIBRARY}/Versions/A/Frameworks/mikmod.framework/Versions/A/mikmod")
set(CMAKE_C_FLAGS "${DYLIB_SMPEG} ${DYLIB_MIKMOD}")
- list(APPEND pascal_flags "-k${DYLIB_SMPEG}" "-k${DYLIB_MIKMOD}")
+ add_flag_append(CMAKE_Pascal_FLAGS "-k${DYLIB_SMPEG}" "-k${DYLIB_MIKMOD}")
endif()
#CMAKE_OSX_ARCHITECTURES and CMAKE_OSX_SYSROOT need to be set for universal binary and correct linking
@@ -190,10 +190,8 @@
endif()
endif()
- #add user framework directory, other paths can be passed via FPFLAGS
- list(APPEND pascal_flags "-Ff~/Library/Frameworks")
#set deployment target
- list(APPEND pascal_flags "-k-macosx_version_min" "-k${minimum_macosx_version}" "-XR${CMAKE_OSX_SYSROOT}")
+ add_flag_append(CMAKE_Pascal_FLAGS "-k-macosx_version_min -k${minimum_macosx_version} ")
endif(APPLE)
@@ -230,7 +228,7 @@
set(CMAKE_REQUIRED_FLAGS "-Wl,-z -Wl,noexecstack")
check_c_compiler_flag("" HAVE_NOEXECSTACK) #empty because we are testing a linker flag
if(HAVE_NOEXECSTACK)
- list(APPEND pascal_flags "-k-z" "-knoexecstack")
+ add_flag_append(CMAKE_Pascal_FLAGS "-k-z -knoexecstack")
if(NOT ${MINIMAL_FLAGS})
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_REQUIRED_FLAGS}")
endif()
@@ -247,40 +245,24 @@
endif()
endif()
-list(APPEND pascal_flags ${fpflags_parsed} # user flags
- "-B" # compile all units
- "-vm4079,4080,4081" # fpc verbosity output format
- "-FE${PROJECT_BINARY_DIR}/bin" # fpc binaries output directory
- "-FU${PROJECT_BINARY_DIR}/hedgewars" # fpc units output directory
- "-Fl${PROJECT_BINARY_DIR}/bin" # fpc linking directory (win/unix)
- "-Fi${PROJECT_BINARY_DIR}/hedgewars" # fpc .inc path (for out of source builds)
- "-k-L${PROJECT_BINARY_DIR}/bin" # ld linking directory (unix/osx)
- "-Cs2000000" # stack size
- "-vewnq" # fpc output verbosity
- "-dDEBUGFILE" # macro for engine output
- )
+
list(APPEND haskell_flags ${ghflags_parsed} # user flags
"-O2" # optimise for faster code
)
+add_flag_append(CMAKE_Pascal_FLAGS "-vm4079,4080,4081 -Cs2000000 -vewnq")
+add_flag_append(CMAKE_Pascal_FLAGS_DEBUG "-O- -g -gl -gv")
+add_flag_append(CMAKE_Pascal_FLAGS_RELEASE "-Os -Xs -Si")
#get BUILD_TYPE and enable/disable optimisation
message(STATUS "Using ${CMAKE_BUILD_TYPE} configuration")
if(CMAKE_BUILD_TYPE MATCHES "DEBUG")
- list(APPEND pascal_flags "-O-" # disable all optimisations
- "-g" # enable debug symbols
- "-gl" # add line info to bt
- "-gv" # allow valgrind
- )
+
list(APPEND haskell_flags "-Wall" # all warnings
"-debug" # debug mode
"-dcore-lint" # internal sanity check
)
else()
- list(APPEND pascal_flags "-Os" # optimise for size
- "-Xs" # strip binary
- "-Si" # turn on inlining
- )
list(APPEND haskell_flags "-w" # no warnings
)
endif()
@@ -295,7 +277,7 @@
message(STATUS "LUA will be provided by the bundled sources")
add_subdirectory(misc/liblua)
#linking with liblua.a requires system readline
- list(APPEND pascal_flags "-k${EXECUTABLE_OUTPUT_PATH}/lib${LUA_LIBRARY}.a" "-k-lreadline")
+ add_flag_append(CMAKE_Pascal_FLAGS "-k${EXECUTABLE_OUTPUT_PATH}/lib${LUA_LIBRARY}.a -k-lreadline")
endif()
@@ -328,10 +310,6 @@
message(STATUS "PhysFS will be provided by the bundled sources")
set(physfs_output_name "hw_physfs")
add_subdirectory(misc/libphysfs)
- #-XLA is a beta fpc flag that renames libraries before passing them to the linker
- #we also have to pass PHYSFS_INTERNAL to satisfy windows runtime requirements
- #(should be harmless on other platforms)
- set(CMAKE_Pascal_FLAGS "-XLAphysfs=${physfs_output_name} -dPHYSFS_INTERNAL ${CMAKE_Pascal_FLAGS}")
endif()
find_package_or_disable_msg(FFMPEG NOVIDEOREC "Video recording will not be built")
--- a/hedgewars/CMakeLists.txt Tue Mar 19 09:53:12 2013 +0100
+++ b/hedgewars/CMakeLists.txt Tue Mar 19 10:34:46 2013 +0100
@@ -8,12 +8,12 @@
#Mix_Init/Mix_Quit from SDL_mixer 1.2.10
check_library_exists(${SDLMIXER_LIBRARY} Mix_Init "" HAVE_MIXINIT)
if(HAVE_MIXINIT)
- list(APPEND pascal_flags "-dSDL_MIXER_NEWER")
+ add_definitions(-dSDL_MIXER_NEWER)
endif()
#IMG_Init/IMG_Quit from SDL_image 1.2.8
check_library_exists(${SDLIMAGE_LIBRARY} IMG_Init "" HAVE_IMGINIT)
if(HAVE_IMGINIT)
- list(APPEND pascal_flags "-dSDL_IMAGE_NEWER")
+ add_definitions(-dSDL_IMAGE_NEWER)
endif()
@@ -106,16 +106,11 @@
if(${BUILD_ENGINE_LIBRARY})
message(${WARNING} "Engine will be built as library (experimental)")
- list(APPEND pascal_flags "-dHWLIBRARY")
-
- # create position independent code, only required for x68_64 builds, similar to -fPIC
- if(CMAKE_SIZEOF_VOID_P MATCHES "8")
- list(APPEND pascal_flags "-Cg")
- endif(CMAKE_SIZEOF_VOID_P MATCHES "8")
+ add_definitions(-dHWLIBRARY)
# due to compiler/linker issues on Max OS X 10.6 -k-no_order_inits is needed to avoid linking fail
if(APPLE AND current_macosx_version VERSION_GREATER "10.5")
- list(APPEND pascal_flags "-k-no_order_inits")
+ add_flag_append(CMAKE_Pascal_FLAGS "-k-no_order_inits")
endif()
set(destination_dir ${target_library_install_dir})
else(${BUILD_ENGINE_LIBRARY})
@@ -147,38 +142,12 @@
if(NOT ${BUILD_ENGINE_LIBRARY})
#let's look for the installed sdlmain file; if it is not found, let's build our own
find_package(SDL REQUIRED)
- #remove the ";-framework Cocoa" from the SDL_LIBRARY variable
- string(REGEX REPLACE "(.*);-.*" "\\1" sdl_library_only "${SDL_LIBRARY}")
- #find libsdmain.a
- find_file(SDLMAIN_LIB libSDLMain.a PATHS ${sdl_library_only}/Resources/)
-
- if(SDLMAIN_LIB MATCHES "SDLMAIN_LIB-NOTFOUND")
- include_directories(${SDL_INCLUDE_DIR})
- add_library (SDLmain STATIC SDLMain.m)
- #add a dependency to the hwengine target
- list(APPEND engine_sources SDLmain)
- set(SDLMAIN_LIB "${LIBRARY_OUTPUT_PATH}/libSDLmain.a")
- endif()
-
- list(APPEND pascal_flags "-k${SDLMAIN_LIB}")
+ include_directories(${SDL_INCLUDE_DIR})
+ add_library (SDLmain STATIC SDLMain.m)
+ add_flag_append(CMAKE_Pascal_FLAGS -Fl${LIBRARY_OUTPUT_PATH})
endif()
-
- #when you have multiple ld installation make sure you get the one bundled with the compiler
- get_filename_component(compiler_dir ${CMAKE_C_COMPILER} PATH)
- list(APPEND pascal_flags "-FD${compiler_dir}")
endif(APPLE)
-#this command is a workaround to some inlining issues present in older FreePascal versions and fixed in 2.6
-if(FREEPASCAL_VERSION VERSION_LESS "2.6")
- #under some configurations CMAKE_BUILD_TOOL fails to pass on the jobserver, breaking parallel compilation
- if(UNIX)
- set(SAFE_BUILD_TOOL $(MAKE))
- else()
- set(SAFE_BUILD_TOOL ${CMAKE_BUILD_TOOL})
- endif()
- add_custom_target(ENGINECLEAN COMMAND ${SAFE_BUILD_TOOL} "clean" "${PROJECT_BINARY_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}")
-endif()
-
if(${FFMPEG_FOUND})
# TODO: this check is only for SDL < 2
@@ -187,35 +156,41 @@
#TODO: convert avwrapper to .pas unit so we can skip this step
include_directories(${FFMPEG_INCLUDE_DIR})
- list(APPEND pascal_flags "-dUSE_VIDEO_RECORDING")
if(WIN32)
# there are some problems with linking our avwrapper as static lib, so link it as shared
add_library(avwrapper SHARED avwrapper.c)
target_link_libraries(avwrapper ${FFMPEG_LIBRARIES})
- install(PROGRAMS "${EXECUTABLE_OUTPUT_PATH}/${CMAKE_SHARED_LIBRARY_PREFIX}avwrapper${CMAKE_SHARED_LIBRARY_SUFFIX}" DESTINATION ${target_library_install_dir})
+ install(PROGRAMS "${LIBRARY_OUTPUT_PATH}/${CMAKE_SHARED_LIBRARY_PREFIX}avwrapper${CMAKE_SHARED_LIBRARY_SUFFIX}" DESTINATION ${target_library_install_dir})
else()
add_library(avwrapper STATIC avwrapper.c)
endif()
+ add_definitions(-dUSE_VIDEO_RECORDING)
+ add_flag_append(CMAKE_Pascal_FLAGS -Fl${LIBRARY_OUTPUT_PATH})
endif()
find_package_or_disable_msg(PNG NOPNG "Screenshots will be saved in BMP")
if(PNG_FOUND)
get_filename_component(PNG_LIB_DIR ${PNG_LIBRARY} PATH)
- add_definitions(-dPNG_SCREENSHOTS -Fl${PNG_LIB_DIR})
+ add_definitions(-dPNG_SCREENSHOTS)
+ add_flag_append(CMAKE_Pascal_FLAGS -Fl${PNG_LIB_DIR})
endif()
-
-set(CMAKE_Pascal_FLAGS "-vm4079,4080,4081 -Fl${PROJECT_BINARY_DIR}/bin -Cs2000000 -vewnq -dDEBUGFILE ${CMAKE_Pascal_FLAGS}")
-add_executable(hwengine ${engine_sources})
+if(NOT PHYSFS_FOUND)
+ #-XLA is a beta fpc flag that renames libraries before passing them to the linker
+ #we also have to pass PHYSFS_INTERNAL to satisfy windows runtime requirements
+ #(should be harmless on other platforms)
+ add_flag_append(CMAKE_Pascal_FLAGS "-XLAphysfs=${physfs_output_name}")
+ add_definitions(-dPHYSFS_INTERNAL)
+endif()
if(APPLE)
- set(CMAKE_Pascal_FLAGS "-Px86_64 -k-llua -k${SDLMAIN_LIB} ${CMAKE_Pascal_FLAGS}")
+ add_flag_append(CMAKE_Pascal_FLAGS -Px86_64)
else()
- set(CMAKE_Pascal_FLAGS "-Pi386 ${CMAKE_Pascal_FLAGS}")
+ add_flag_append(CMAKE_Pascal_FLAGS -Pi386)
endif()
-set(fpc_flags ${pascal_flags} ${hwengine_project})
-#add_custom_target(hwengine ALL DEPENDS "${EXECUTABLE_OUTPUT_PATH}/${engine_output_name}")
+add_definitions(-dDEBUGFILE)
+add_executable(hwengine ${engine_sources})
#when system Lua is not found we need to compile it before engine
if(NOT LUA_FOUND)
--- a/hedgewars/SDLh.pas Tue Mar 19 09:53:12 2013 +0100
+++ b/hedgewars/SDLh.pas Tue Mar 19 10:34:46 2013 +0100
@@ -58,7 +58,8 @@
{$ENDIF}
{$IFDEF DARWIN}
- {$IFNDEF IPHONEOS}
+ {$IFNDEF HWLIBRARY}
+ {$linklib SDLmain}
{$PASCALMAINNAME SDL_main}
{$linkframework Cocoa}
{$linkframework SDL}