diff options
Diffstat (limited to '')
-rw-r--r-- | cmake/CMakeLists.txt | 41 | ||||
-rw-r--r-- | cmake/dists/cmake/Modules/FindPPC.cmake | 315 | ||||
-rw-r--r-- | cmake/dists/cmake/Modules/UsePascal.cmake | 100 | ||||
-rw-r--r-- | cmake/dists/gentoo/ultrastardx-9999.ebuild | 24 | ||||
-rw-r--r-- | cmake/plugins/5000Points/CMakeLists.txt | 2 | ||||
-rw-r--r-- | cmake/plugins/Blind/CMakeLists.txt | 2 | ||||
-rw-r--r-- | cmake/plugins/CMakeLists.txt | 11 | ||||
-rw-r--r-- | cmake/plugins/Dont_Get_Worse/CMakeLists.txt | 2 | ||||
-rw-r--r-- | cmake/plugins/Duell/CMakeLists.txt | 2 | ||||
-rw-r--r-- | cmake/plugins/Team_Duell/CMakeLists.txt | 2 | ||||
-rw-r--r-- | cmake/src/CMakeLists.txt | 12 | ||||
-rw-r--r-- | cmake/src/lib/JEDI-SDL/SDL/CMakeLists.txt | 9 | ||||
-rw-r--r-- | cmake/src/lib/projectM/cwrapper/CMakeLists.txt | 18 | ||||
-rw-r--r-- | cmake/src/switches.inc | 8 |
14 files changed, 362 insertions, 186 deletions
diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 8eafd2b4..57cb89a9 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -39,7 +39,6 @@ set(CPACK_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSIO set(PACKAGE_WEBSITE "http://www.ultrastardeluxe.org/") set(PACKAGE_IRC "#ultrastardx at quakenet.org") - ## # MAIN DEPENDENCIES ## @@ -69,6 +68,8 @@ if(NOT WIN32) else(SDLIMAGE_LIBRARY) message(FATAL_ERROR "Looking for SDL_image - missing") endif(SDLIMAGE_LIBRARY) + # hide SDL_image from GUI + mark_as_advanced(SDLIMAGE_LIBRARY SDLIMAGE_INCLUDE_DIR) pkg_check_modules(libpng REQUIRED libpng12) #find_package(PNG REQUIRED) @@ -132,32 +133,23 @@ endif(NOT WIN32) include(FileUtils) +set(USDX_GAME_DIR ${CMAKE_CURRENT_BINARY_DIR}/game) +set(USDX_PLUGIN_DIR ${USDX_GAME_DIR}/plugins) + # init runtime environment for out-of-source builds if(NOT WIN32) if(NOT ${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR}) # create game dir - file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/game) + file(MAKE_DIRECTORY ${USDX_GAME_DIR}) # symlink directories which are shared by all out-of-source builds - file_symlink(${CMAKE_CURRENT_SOURCE_DIR}/game/covers - ${CMAKE_CURRENT_BINARY_DIR}/game/covers) - file_symlink(${CMAKE_CURRENT_SOURCE_DIR}/game/fonts - ${CMAKE_CURRENT_BINARY_DIR}/game/fonts) - file_symlink(${CMAKE_CURRENT_SOURCE_DIR}/game/languages - ${CMAKE_CURRENT_BINARY_DIR}/game/languages) - file_symlink(${CMAKE_CURRENT_SOURCE_DIR}/game/resources - ${CMAKE_CURRENT_BINARY_DIR}/game/resources) - file_symlink(${CMAKE_CURRENT_SOURCE_DIR}/game/sounds - ${CMAKE_CURRENT_BINARY_DIR}/game/sounds) - file_symlink(${CMAKE_CURRENT_SOURCE_DIR}/game/themes - ${CMAKE_CURRENT_BINARY_DIR}/game/themes) - file_symlink(${CMAKE_CURRENT_SOURCE_DIR}/game/visuals - ${CMAKE_CURRENT_BINARY_DIR}/game/visuals) + foreach(subdir covers fonts languages resources sounds themes visuals) + file_symlink(${CMAKE_CURRENT_SOURCE_DIR}/game/${subdir} ${USDX_GAME_DIR}/${subdir}) + endforeach(subdir) # copy directories which are either changed by the build process # or while execution - file_copy_dir(${CMAKE_CURRENT_SOURCE_DIR}/game/plugins - ${CMAKE_CURRENT_BINARY_DIR}/game/plugins) + file_copy_dir(${CMAKE_CURRENT_SOURCE_DIR}/game/plugins ${USDX_PLUGIN_DIR}) endif() endif(NOT WIN32) @@ -175,6 +167,8 @@ add_subdirectory(plugins) get_target_property(usdx_exe ultrastardx PASCAL_LOCATION) install(PROGRAMS ${usdx_exe} DESTINATION bin) +set(USDX_INSTALL_DATA_DIR share/ultrastardx) + install( DIRECTORY artwork @@ -184,14 +178,19 @@ install( game/resources game/sounds game/themes - ${CMAKE_CURRENT_BINARY_DIR}/game/plugins - DESTINATION share/ultrastardx + DESTINATION ${USDX_INSTALL_DATA_DIR} + PATTERN .svn EXCLUDE +) +install( + DIRECTORY ${USDX_PLUGIN_DIR} + DESTINATION ${USDX_INSTALL_DATA_DIR} + USE_SOURCE_PERMISSIONS PATTERN .svn EXCLUDE ) install( FILES COPYING.txt - DESTINATION share/ultrastardx + DESTINATION ${USDX_INSTALL_DATA_DIR} ) # add "uninstall" target diff --git a/cmake/dists/cmake/Modules/FindPPC.cmake b/cmake/dists/cmake/Modules/FindPPC.cmake index 3f82b720..2c4f2da3 100644 --- a/cmake/dists/cmake/Modules/FindPPC.cmake +++ b/cmake/dists/cmake/Modules/FindPPC.cmake @@ -7,195 +7,282 @@ # - Find Pascal compiler # # This module defines -# PPC_FOUND, If false, do not try to use PPC. - -## -# Find FreePascal executable -## - -set(PPC_BIN_PATH - "$ENV{SystemDrive}/fpc/*/bin/*" - "$ENV{ProgramFiles}/fpc/*/bin/*" - "$ENV{SystemDrive}/lazarus/fpc/*/bin/*" - "$ENV{ProgramFiles}/lazarus/fpc/*/bin/*" -) -find_program(PPC fpc PATHS ${PPC_BIN_PATH}) +# PPC_FOUND: If false, do not try to use PPC. +# PASCAL_COMPILER_TYPE: Either FPC or DELPHI (latter not yet supported) +# PASCAL_COMPILER_WORKS: True if the compiler works +# PASCAL_FLAGS_...: Some default flags for several build types +# PASCAL_FLAGS +# PASCAL_LIBRARY_FLAGS +# PASCAL_FLAGS_DEBUG +# PASCAL_FLAGS_RELEASE +# PASCAL_FLAGS_RELWITHDEBINFO +# PASCAL_FLAGS_MINSIZEREL +# PASCAL_LIBRARY_BUILD_WORKS: Compiler/linker combination is able to build libraries. +# PASCAL_LIBRARY_SUFFIX: Library suffix (e.g. .dll or .so) +# PASCAL_LIBRARY_PREFIX: Library prefix (e.g. lib) +# FPC_PLATFORM: Target platform (OS): linux, freebsd, openbsd, netbsd, darwin, win32, ... +# FPC_PROCESSOR: Target processor (CPU): i386, x86_64, powerpc, arm +# FPC_CPLATFORM: Compiler platform (OS) +# FPC_CPROCESSOR: Compiler processor (CPU) +# FPC_TARGET: String "FPC_PROCESSOR-FPC_PLATFORM" ## # Get FPC compiler info ## -set(PPC_CHECK_DIR ${CMAKE_BINARY_DIR}/ppc_check) +set(current_pkg PPC) +set(ppc_check_dir ${CMAKE_BINARY_DIR}/ppc_check) -# - creates file with code in PPC_CHECK_DIR and compiles it with +# - creates file with code in ppc_check_dir and compiles it with # the given flags. The result will be stored in result_var. -# If NO_CLEAN is given, the PPC_CHECK_DIR will not be removed +# If NO_CLEAN is given, the ppc_check_dir will not be removed # after the check. # -# PPC_CHECK(file code flags result_var NO_CLEAN) +# ppc_check(file code flags result_var NO_CLEAN) # -function(PPC_CHECK file code flags result_var) +function(ppc_check file code flags result_var) # create compiler check directory - file(MAKE_DIRECTORY ${PPC_CHECK_DIR}) + file(MAKE_DIRECTORY ${ppc_check_dir}) - file(WRITE ${PPC_CHECK_DIR}/${file} "${code}") + file(WRITE ${ppc_check_dir}/${file} "${code}") execute_process( - COMMAND ${PPC} ${flags} ${file} - WORKING_DIRECTORY ${PPC_CHECK_DIR} + COMMAND ${PASCAL_COMPILER} ${flags} ${file} + WORKING_DIRECTORY ${ppc_check_dir} RESULT_VARIABLE check_result - ERROR_QUIET - OUTPUT_QUIET) + ERROR_VARIABLE check_output + OUTPUT_VARIABLE check_output + ) # remove compiler check directory list(FIND ARGN "NO_CLEAN" no_clean) - if(no_clean EQUAL -1) - file(REMOVE_RECURSE ${PPC_CHECK_DIR}) - endif(no_clean EQUAL -1) + file(REMOVE_RECURSE ${ppc_check_dir}) + endif() + + list(FIND ARGN "SHOW_ERROR" show_error) + if(show_error GREATER -1) + if(check_result AND NOT ${current_pkg}_FIND_QUIETLY) + message("${check_output}") + endif() + endif() set(${result_var} ${check_result} PARENT_SCOPE) -endfunction(PPC_CHECK) +endfunction(ppc_check) # use a foreach statement so we can leave this section with break() # if an error occurs. foreach(once 1) - set(PPC_WORKS) - set(PPC_ERROR) + # clear error message + set(ppc_error) + + # skip tests if compiler was previously found + if(PASCAL_COMPILER_WORKS) + break() + endif(PASCAL_COMPILER_WORKS) - if(NOT PPC) - set(PPC_ERROR "Executable not found") + # Find FreePascal executable + set(ppc_bin_path + "$ENV{SystemDrive}/fpc/*/bin/*" + "$ENV{ProgramFiles}/fpc/*/bin/*" + "$ENV{SystemDrive}/lazarus/fpc/*/bin/*" + "$ENV{ProgramFiles}/lazarus/fpc/*/bin/*" + ) + find_program(PASCAL_COMPILER fpc PATHS ${ppc_bin_path}) + if(NOT PASCAL_COMPILER) + set(ppc_error "Executable not found") break() - endif(NOT PPC) + endif(NOT PASCAL_COMPILER) + + if(NOT ${current_pkg}_FIND_QUIETLY) + message(STATUS "Check for working Pascal compiler: ${PASCAL_COMPILER}") + endif(NOT ${current_pkg}_FIND_QUIETLY) # retrieve FPC version - execute_process(COMMAND ${PPC} -iV + execute_process(COMMAND ${PASCAL_COMPILER} -iV OUTPUT_VARIABLE FPC_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE) # check version - if(PPC_FIND_VERSION_EXACT) - if(NOT FPC_VERSION VERSION_EQUAL PPC_FIND_VERSION) - set(PPC_ERROR "Required =${PPC_FIND_VERSION} but found ${FPC_VERSION}") + if(${current_pkg}_FIND_VERSION_EXACT) + if(NOT FPC_VERSION VERSION_EQUAL ${current_pkg}_FIND_VERSION) + set(ppc_error "Required =${${current_pkg}_FIND_VERSION} but found ${FPC_VERSION}") break() - endif(NOT FPC_VERSION VERSION_EQUAL PPC_FIND_VERSION) - endif(PPC_FIND_VERSION_EXACT) - if(PPC_FIND_VERSION) - if(FPC_VERSION VERSION_LESS PPC_FIND_VERSION) - set(PPC_ERROR "Required >=${PPC_FIND_VERSION} but found ${FPC_VERSION}") + endif(NOT FPC_VERSION VERSION_EQUAL ${current_pkg}_FIND_VERSION) + endif(${current_pkg}_FIND_VERSION_EXACT) + if(${current_pkg}_FIND_VERSION) + if(FPC_VERSION VERSION_LESS ${current_pkg}_FIND_VERSION) + set(ppc_error "Required >=${${current_pkg}_FIND_VERSION} but found ${FPC_VERSION}") break() - endif(FPC_VERSION VERSION_LESS PPC_FIND_VERSION) - endif(PPC_FIND_VERSION) + endif(FPC_VERSION VERSION_LESS ${current_pkg}_FIND_VERSION) + endif(${current_pkg}_FIND_VERSION) # retrieve FPC platform info - execute_process(COMMAND ${PPC} -iTO + execute_process(COMMAND ${PASCAL_COMPILER} -iTO OUTPUT_VARIABLE FPC_PLATFORM OUTPUT_STRIP_TRAILING_WHITESPACE) - execute_process(COMMAND ${PPC} -iTP + execute_process(COMMAND ${PASCAL_COMPILER} -iTP OUTPUT_VARIABLE FPC_PROCESSOR OUTPUT_STRIP_TRAILING_WHITESPACE) - execute_process(COMMAND ${PPC} -iSO + execute_process(COMMAND ${PASCAL_COMPILER} -iSO OUTPUT_VARIABLE FPC_CPLATFORM OUTPUT_STRIP_TRAILING_WHITESPACE) - execute_process(COMMAND ${PPC} -iSP + execute_process(COMMAND ${PASCAL_COMPILER} -iSP OUTPUT_VARIABLE FPC_CPROCESSOR OUTPUT_STRIP_TRAILING_WHITESPACE) set(FPC_TARGET "${FPC_PROCESSOR}-${FPC_PLATFORM}") - - #-v -l verbose/banner - #-n ignore fpc.cfg - #-Fi -I include-dir - #-k - #-Fl linker-dir - #-Fo -Fu object-/unit-dir - #-Xt -Xc - #-Ciort range checks - #-Cs -Ch stack/heap size - #-Cg -fPIC PIC code - #-E - #-g -gv -gw(2/3) -gh -gl -pg - #-O - #-T -Xd -XP cross-compiling - #-d -u define/undefine - #-Xs strip - #-B build all modules - #-Dd -Dv description + DLL-version - - #PFLAGS_BASE_DEFAULT := -Si -Sg- -Sc- -v0Binwe - #PFLAGS_DEBUG_DEFAULT := -Xs- -g -gl -dDEBUG_MODE - #PFLAGS_RELEASE_DEFAULT := -Xs- -O2 - ## # Compiler checks ## - set(default_flags "") + set(check_flags "-l -v0ie") # check whether FPC works and can compile a program - ppc_check(simple.pas "program simple;\nbegin\nend." - "${default_flags}" check_result) + ppc_check(simple.pas "program simple;\nbegin\nend." + "${check_flags}" check_result SHOW_ERROR) if(check_result) - set(PPC_ERROR "Cannot compile simple test-program") + set(ppc_error "Cannot compile simple test-program") break() endif(check_result) # check if FPC can link with standard libraries ppc_check(link.pas "program link;\nuses SysUtils;\nbegin\nWriteLn('Test');\nend." - "${default_flags}" check_result) + "${check_flags}" check_result SHOW_ERROR) if(check_result) - set(PPC_ERROR "Cannot link with standard libraries") + set(ppc_error "Cannot link with standard libraries") break() endif(check_result) - # check whether FPC's linker knows (or at least doesn't crash with) - # "-z noexecstack" + # check whether FPC's linker knows (or at least doesn't crash with) "-z noexecstack". # FPC does not set the NX-flag on stack memory. Binaries generated with FPC # might crash on platforms that require the stack to be non-executable. # So we will try to find a workaround here. # See http://bugs.freepascal.org/view.php?id=11563 - set(noexecstack_flags -k"-z noexecstack") ppc_check(noexecstack.pas "program noexecstack;\nbegin\nend." - "${default_flags} ${noexecstack_flags}" check_result) - if(check_result) - set(noexecstack_flags) - endif(check_result) + "${check_flags};-k-z noexecstack" check_result) + if(NOT check_result) + set(noexecstack_flag "-k\"-z noexecstack\"") + endif(NOT check_result) - # check prefixes and suffixes + # check if compiler is able to build libraries + set(lib_build_works TRUE) ppc_check(testlib.pas "library link;\nbegin\nend." - "${default_flags}" check_result + "${check_flags}" check_result NO_CLEAN) - # find generated library - find_library(PPC_TEST_LIBPATH testlib - PATHS ${PPC_CHECK_DIR} - NO_DEFAULT_PATH) - # do not show library name in GUI - mark_as_advanced(PPC_TEST_LIBPATH) - # extract prefix and suffix from library name - if(PPC_TEST_LIBPATH) - get_filename_component(PPC_LIBRARY_SUFFIX ${PPC_TEST_LIBPATH} EXT CACHE) - get_filename_component(libfilename ${PPC_TEST_LIBPATH} NAME_WE) - string(REGEX REPLACE "^(.*)testlib.*" "\\1" PPC_LIBRARY_PREFIX ${libfilename}) - endif(PPC_TEST_LIBPATH) - # remove library test directory - file(REMOVE_RECURSE ${PPC_CHECK_DIR}) if(check_result) - set(PPC_ERROR "Cannot link with standard libraries") - break() - endif(check_result) + # The linker (ld) cannot link the library. Ubuntu with ld 2.19.1 + # is known to fail here because of a bug so do not break here. + if(NOT ${current_pkg}_FIND_QUIETLY) + message(STATUS "Pascal compiler cannot build shared libraries!") + endif(NOT ${current_pkg}_FIND_QUIETLY) + set(lib_build_works FALSE) + else(check_result) + # find generated library + find_library(PASCAL_TESTLIB_PATH testlib + PATHS ${ppc_check_dir} + NO_DEFAULT_PATH) + # do not show library name in GUI + mark_as_advanced(PASCAL_TESTLIB_PATH) + # extract prefix and suffix from library name + if(PASCAL_TESTLIB_PATH) + get_filename_component(lib_suffix ${PASCAL_TESTLIB_PATH} EXT) + get_filename_component(testlib_filename ${PASCAL_TESTLIB_PATH} NAME_WE) + string(REGEX REPLACE "^(.*)testlib.*" "\\1" lib_prefix ${testlib_filename}) + mark_as_advanced(PASCAL_LIBRARY_PREFIX PASCAL_LIBRARY_SUFFIX) + endif(PASCAL_TESTLIB_PATH) - ## - # Check results - ## + # set cache entries + set(PASCAL_LIBRARY_SUFFIX ${lib_suffix} CACHE STRING "Pascal library suffix.") + set(PASCAL_LIBRARY_PREFIX ${lib_prefix} CACHE STRING "Pascal library prefix.") + endif(check_result) + # remove test directory + file(REMOVE_RECURSE ${ppc_check_dir}) - #set(PFLAGS ${noexecstack_flags} "-B" "-FE../bin" "-Cs2000000" "-vwi" "-O2" "-Fl/opt/local/lib" ${hwengine_project}) + # cache results + set(PASCAL_COMPILER_WORKS TRUE CACHE INTERNAL "") + set(PASCAL_LIBRARY_BUILD_WORKS ${lib_build_works} CACHE INTERNAL "") + set(PASCAL_COMPILER_TYPE FPC CACHE INTERNAL "") - set(PPC_WORKS TRUE) + if(NOT ${current_pkg}_FIND_QUIETLY) + message(STATUS "Check for working Pascal compiler: ${PASCAL_COMPILER} -- works") + endif(NOT ${current_pkg}_FIND_QUIETLY) endforeach(once) -# handle the QUIETLY and REQUIRED arguments and set PPC_FOUND to TRUE if -# all listed variables are TRUE -INCLUDE(FindPackageHandleStandardArgs) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(PPC "Could NOT find PPC: ${PPC_ERROR}!" PPC PPC_WORKS) +## +# Set Flags +## + +# default flags. +# Notes: +# - The flags defined in fpc.cfg are evaluated first in a first pass. +# This also applies those flags that are enabled by defining -dDEBUG or -dRELEASE. +# In a second pass all command line options are evaluated. +# This way all flags defined in fpc.cfg can be undefined with -<flag>- +# - FPC strips binaries by default. Stripping binaries is considered bad style, +# for example Gentoo reacts to stripped binaries with a quality warning. +# In addition the cmake installer strips the binaries if required. +# Disable stripping with -Xs-. +set(PASCAL_FLAGS + "-Xs- -v0Binwe ${noexecstack_flag}" + CACHE STRING "Flags used by the Pascal compiler during all build types.") +separate_arguments(PASCAL_FLAGS) + +# default library flags. Some Linux distribution's security policies require -fPIC, +# otherwise linking will fail. +if(UNIX) + # FPC supports PIC for Darwin and Linux/x86_64 but Linux/i386 is broken with 2.2.2. + # See http://community.freepascal.org:10000/bboards/message?message_id=314214&forum_id=24092 + if(NOT FPC_PLATFORM STREQUAL linux OR NOT FPC_PROCESSOR STREQUAL i386) + set(PIC_flag "-fPIC") + endif() +endif(UNIX) +set(PASCAL_LIBRARY_FLAGS + "${PIC_flag}" + CACHE STRING "Flags used by the Pascal compiler during library builds.") +separate_arguments(PASCAL_LIBRARY_FLAGS) + +# Some debug flags to keep in mind: -gv -gw(2/3) -gh -pg +set(debug_info_flags "-g -gl") + +# default debug flags. Define DEBUG but remove some ill-suited flags set in fpc.cfg (-Crtoi). +set(PASCAL_FLAGS_DEBUG + "-dDEBUG -Cr-t-o-i- ${debug_info_flags}" + CACHE STRING "Flags used by the Pascal compiler during debug builds.") +separate_arguments(PASCAL_FLAGS_DEBUG) + +set(release_base_flags "-dRELEASE -vn-") + +# default release flags. Define RELEASE but remove some ill-suited flags set in fpc.cfg (-Xs) +# Enable optimization, reduce verbosity by disabling notes. +set(PASCAL_FLAGS_RELEASE + "${release_base_flags} -O2" + CACHE STRING "Flags used by the Pascal compiler during release builds.") +separate_arguments(PASCAL_FLAGS_RELEASE) + +set(PASCAL_FLAGS_RELWITHDEBINFO + "${release_base_flags} -O2 ${debug_info_flags}" + CACHE STRING "Flags used by the Pascal compiler during Release with Debug Info builds.") +separate_arguments(PASCAL_FLAGS_RELWITHDEBINFO) + +set(PASCAL_FLAGS_MINSIZEREL + "${release_base_flags} -Os" + CACHE STRING "Flags used by the Pascal compiler during release minsize builds.") +separate_arguments(PASCAL_FLAGS_MINSIZEREL) + +## +# set PPC_FOUND and show error messages +## -mark_as_advanced(PPC) +set(fail_message "No working Pascal compiler found: ${ppc_error}!") +if(PASCAL_COMPILER_WORKS) + set(${current_pkg}_FOUND TRUE) +else(PASCAL_COMPILER_WORKS) + if(${current_pkg}_FIND_REQUIRED) + message(FATAL_ERROR "${fail_message}") + else(${current_pkg}_FIND_REQUIRED) + if(NOT ${current_pkg}_FIND_QUIETLY) + message(STATUS "${fail_message}") + endif(NOT ${current_pkg}_FIND_QUIETLY) + endif(${current_pkg}_FIND_REQUIRED) +endif(PASCAL_COMPILER_WORKS) diff --git a/cmake/dists/cmake/Modules/UsePascal.cmake b/cmake/dists/cmake/Modules/UsePascal.cmake index e3c3612b..7a7ade08 100644 --- a/cmake/dists/cmake/Modules/UsePascal.cmake +++ b/cmake/dists/cmake/Modules/UsePascal.cmake @@ -11,12 +11,19 @@ # (mostly used for header files). # This information will be appended to a module generated by # add_pascal_module() if a package is specified with the PACKAGE -# option. +# option. +# You can pass additional compiler flags with +# <COMPILER>_FLAGS (for all module types) and +# <COMPILER>_LIBRARY_FLAGS (for libraries only) +# where <COMPILER> must be either FPC or DELPHI. # PASCAL_ADD_PACKAGE( # <name> # [UNITS file1 [...]] # [INCLUDES file1 [...]] # [OBJECT_DIRS dir1 [...]] +# [<COMPILER>_FLAGS ...] +# [<COMPILER>_LIBRARY_FLAGS] +# ) # # - Builds a Pascal module. # The module can be a program, library or unit. The type is either autodetected @@ -46,16 +53,18 @@ # Units/includes used by packages specified by the PACKAGES option do not have to be specified # again with UNITS/INCLUDES. Package sources are not appended to auto-generated project files # for lazarus. +# You can pass additional compiler flags with <COMPILER>_FLAGS where <COMPILER> +# must be one of FPC or DELPHI. # Sets target properties: -# - PASCAL_TYPE: module type (one of PROGRAM/LIBRARY/UNIT) -# - PASCAL_LOCATION: full path of output file (equivalent to LOCATION) +# - PASCAL_TYPE: module type (one of PROGRAM/LIBRARY/UNIT) +# - PASCAL_LOCATION: full path of output file (equivalent to LOCATION) # PASCAL_ADD_MODULE( # <name> # [PROGRAM | LIBRARY | UNIT] # <main_source> # [OUTPUT_NAME name] # [OUTPUT_DIR dir] -# [FLAGS ...] +# [<COMPILER>_FLAGS ...] # [DEPENDS depend [...]] # [UNITS file1 [...]] # [INCLUDES file1 [...]] @@ -79,13 +88,22 @@ include(LazarusGenerator) option(GENERATE_LAZARUS_PROJECTS "Generate lazarus project files (.lpi) for every Pascal target" OFF) function(PASCAL_ADD_PACKAGE name) + # setup a list of property names to copy from the arguments + set(prop_list) + list(APPEND prop_list OBJECT_DIRS) + foreach(comp FPC DELPHI) + list(APPEND prop_list ${comp}_FLAGS ${comp}_LIBRARY_FLAGS) + endforeach(comp) + + # parse arguments set(ARG) parse_arguments(ARG - "UNITS;INCLUDES;OBJECT_DIRS" + "UNITS;INCLUDES;${prop_list}" "" ${ARGN} ) + # transform file paths to absolute paths set(unit_abs_list) foreach(unit ${ARG_UNITS}) get_filename_component(unit_abs ${unit} ABSOLUTE) @@ -97,16 +115,19 @@ function(PASCAL_ADD_PACKAGE name) list(APPEND inc_abs_list ${inc_abs}) endforeach(inc) + # store info in global properties set_property(GLOBAL PROPERTY PASCAL_PKG_${name}_EXISTS TRUE) set_property(GLOBAL PROPERTY PASCAL_PKG_${name}_UNITS "${unit_abs_list}") set_property(GLOBAL PROPERTY PASCAL_PKG_${name}_INCLUDES "${inc_abs_list}") - set_property(GLOBAL PROPERTY PASCAL_PKG_${name}_OBJECT_DIRS "${ARG_OBJECT_DIRS}") + foreach(prop ${prop_list}) + set_property(GLOBAL PROPERTY PASCAL_PKG_${name}_${prop} "${ARG_${prop}}") + endforeach(prop) endfunction(PASCAL_ADD_PACKAGE) macro(PASCAL_ADD_MODULE) set(ARG) - parse_arguments(ARG - "OUTPUT_NAME;OUTPUT_DIR;FLAGS;DEPENDS;UNITS;INCLUDES;OBJECT_DIRS;PACKAGES" + parse_arguments(ARG + "OUTPUT_NAME;OUTPUT_DIR;DEPENDS;UNITS;INCLUDES;OBJECT_DIRS;PACKAGES;FPC_FLAGS;DELPHI_FLAGS" "EXCLUDE_FROM_ALL;REBUILD_ALL" ${ARGN} ) @@ -197,7 +218,7 @@ macro(PASCAL_ADD_MODULE) list(APPEND extra_clean_files ${output}) endif(type STREQUAL PROGRAM) if(type STREQUAL LIBRARY) - set(output "${output_dir}/${PPC_LIBRARY_PREFIX}${output_name}${PPC_LIBRARY_SUFFIX}") + set(output "${output_dir}/${PASCAL_LIBRARY_PREFIX}${output_name}${PASCAL_LIBRARY_SUFFIX}") list(APPEND extra_clean_files ${output}) endif(type STREQUAL LIBRARY) if(type STREQUAL UNIT) @@ -212,6 +233,24 @@ macro(PASCAL_ADD_MODULE) # set working dir set(work_dir ${CMAKE_CURRENT_SOURCE_DIR}) + # assemble pascal compiler flags + set(pflags ${PASCAL_FLAGS}) + if(type STREQUAL LIBRARY) + list(APPEND pflags ${PASCAL_LIBRARY_FLAGS}) + endif(type STREQUAL LIBRARY) + if(CMAKE_BUILD_TYPE STREQUAL Release) + list(APPEND pflags ${PASCAL_FLAGS_RELEASE}) + elseif(CMAKE_BUILD_TYPE STREQUAL Debug) + list(APPEND pflags ${PASCAL_FLAGS_DEBUG}) + elseif(CMAKE_BUILD_TYPE STREQUAL RelWithDebInfo) + list(APPEND pflags ${PASCAL_FLAGS_RELWITHDEBINFO}) + elseif(CMAKE_BUILD_TYPE STREQUAL MinSizeRelDebug) + list(APPEND pflags ${PASCAL_FLAGS_MINSIZEREL}) + endif() + + # set target specific flags + list(APPEND pflags ${ARG_${PASCAL_COMPILER_TYPE}_FLAGS}) + # init unit/include/object dir list set(unit_dirs "") set(inc_dirs "") @@ -219,23 +258,39 @@ macro(PASCAL_ADD_MODULE) # add packages foreach(pkg ${ARG_PACKAGES}) + # check existence set(pkg_exists) get_property(pkg_exists GLOBAL PROPERTY PASCAL_PKG_${pkg}_EXISTS) if(NOT pkg_exists) message(FATAL_ERROR "Unknown pascal package \"${pkg}\". See pascal_add_package().") endif(NOT pkg_exists) + # append package units set(pkg_units) get_property(pkg_units GLOBAL PROPERTY PASCAL_PKG_${pkg}_UNITS) list(APPEND units ${pkg_units}) + # append package includes set(pkg_incs) get_property(pkg_incs GLOBAL PROPERTY PASCAL_PKG_${pkg}_INCLUDES) list(APPEND incs ${pkg_incs}) + # append package object dirs set(pkg_obj_dirs) get_property(pkg_obj_dirs GLOBAL PROPERTY PASCAL_PKG_${pkg}_OBJECT_DIRS) list(APPEND obj_dirs ${pkg_obj_dirs}) + + # append package flags + set(pkg_flags) + get_property(pkg_flags GLOBAL PROPERTY PASCAL_PKG_${pkg}_${PASCAL_COMPILER_TYPE}_FLAGS) + list(APPEND pflags ${pkg_flags}) + + # append package library flags if appropriate + if(type STREQUAL LIBRARY) + set(pkg_lib_flags) + get_property(pkg_lib_flags GLOBAL PROPERTY PASCAL_PKG_${pkg}_${PASCAL_COMPILER_TYPE}_LIBRARY_FLAGS) + list(APPEND pflags ${pkg_lib_flags}) + endif(type STREQUAL LIBRARY) endforeach(pkg ${ARG_PACKAGES}) # add unit/include/object dirs passed as macro parameter @@ -279,8 +334,7 @@ macro(PASCAL_ADD_MODULE) # add *.pas/*.pp of each unit-dir and *.inc of each inc-dir # to the depends list set(depends) - list(APPEND depends ${units}) - list(APPEND depends ${incs}) + list(APPEND depends ${units} ${incs}) # check if we are to add the target to ALL set(custom_target_all "ALL") @@ -290,12 +344,16 @@ macro(PASCAL_ADD_MODULE) # check if even unchanged units should be rebuild if(ARG_REBUILD_ALL) - list(APPEND PFLAGS -B) + # Note that the -B (build all modules) option does not work if not all + # unit-directories the project uses are passed with the -Fu flag. + # Sources in directories not given with -Fu (even if listed in the dpr/lpr file) + # are never recompiled. + # As a safer method clean the unit-output directory instead but keep + # the -B flag for lazarus project files as it does not hurt. + set(unit_out_clean COMMAND ${CMAKE_COMMAND} -E remove_directory ${unit_out_dir}) + list(APPEND pflags -B) endif(ARG_REBUILD_ALL) - # set flags - list(APPEND PFLAGS ${ARG_FLAGS}) - # lower-case project type (just for user info) string(TOLOWER ${type} proj_type_lowcase) @@ -309,12 +367,11 @@ macro(PASCAL_ADD_MODULE) add_custom_command( OUTPUT ${target_timestamp} # delete and create units dir (needed for proper update) -# COMMAND ${CMAKE_COMMAND} -E remove_directory ${unit_out_dir} + ${unit_out_clean} COMMAND ${CMAKE_COMMAND} -E make_directory ${unit_out_dir} # build - COMMAND ${PPC} -# -l- -vi- - ${PFLAGS} + COMMAND ${PASCAL_COMPILER} + ${pflags} ${dir_flag_list} -FU${unit_out_dir} -o${output} @@ -328,7 +385,8 @@ macro(PASCAL_ADD_MODULE) ) # add target - add_custom_target(${target} ${custom_target_all} + add_custom_target(${target} + ${custom_target_all} COMMENT "Checking dependencies of target ${target}" DEPENDS ${target_timestamp} ) @@ -350,7 +408,7 @@ macro(PASCAL_ADD_MODULE) "${ARG_INCLUDES}" "${inc_dirs}" "${obj_dirs}" - "${PFLAGS}" + "${pflags}" ) endif(GENERATE_LAZARUS_PROJECTS) endmacro(PASCAL_ADD_MODULE) diff --git a/cmake/dists/gentoo/ultrastardx-9999.ebuild b/cmake/dists/gentoo/ultrastardx-9999.ebuild index 7b092919..b1ffb5a4 100644 --- a/cmake/dists/gentoo/ultrastardx-9999.ebuild +++ b/cmake/dists/gentoo/ultrastardx-9999.ebuild @@ -2,7 +2,7 @@ # Distributed under the terms of the GNU General Public License v2 # $Header $ -inherit subversion eutils games +inherit subversion cmake-utils games SONGS_PKG=USDX-SongPackage SONGS_VER=01 @@ -34,7 +34,7 @@ RDEPEND="virtual/opengl projectm? ( media-libs/libprojectm )" DEPEND="${RDEPEND} dev-util/pkgconfig - >=dev-lang/fpc-2.2.0" + >=dev-lang/fpc-2.2.2" S=${WORKDIR}/${P}-src @@ -50,10 +50,22 @@ src_unpack() { } src_compile() { - egamesconf \ - $(use_with projectm libprojectM) \ - $(use_enable debug) \ - || die + if use projectm ; then + enable_projectm="ON" + else + enable_projectm="OFF" + fi + if use debug ; then + build_type="Debug" + else + build_type="Release" + fi + cmake \ + -DCMAKE_BUILD_TYPE=$build_type \ + -DENABLE_PROJECTM=$enable_projectm \ + -DCMAKE_INSTALL_PREFIX="/usr" \ + . \ + || die "cmake failed" emake || die "emake failed" } diff --git a/cmake/plugins/5000Points/CMakeLists.txt b/cmake/plugins/5000Points/CMakeLists.txt index 2d0c7008..ecc89b00 100644 --- a/cmake/plugins/5000Points/CMakeLists.txt +++ b/cmake/plugins/5000Points/CMakeLists.txt @@ -1,4 +1,4 @@ # $URL$ # $Id$ -pascal_add_module(until5000 Until5000.dpr) +pascal_add_module(until5000 Until5000.dpr OUTPUT_DIR ${USDX_PLUGIN_DIR} EXCLUDE_FROM_ALL) add_dependencies(plugins until5000) diff --git a/cmake/plugins/Blind/CMakeLists.txt b/cmake/plugins/Blind/CMakeLists.txt index f80c346b..350ba13e 100644 --- a/cmake/plugins/Blind/CMakeLists.txt +++ b/cmake/plugins/Blind/CMakeLists.txt @@ -1,4 +1,4 @@ # $URL$ # $Id$ -pascal_add_module(blind Blind.dpr) +pascal_add_module(blind Blind.dpr OUTPUT_DIR ${USDX_PLUGIN_DIR} EXCLUDE_FROM_ALL) add_dependencies(plugins blind) diff --git a/cmake/plugins/CMakeLists.txt b/cmake/plugins/CMakeLists.txt index 21f4ba5b..d7cd8ae6 100644 --- a/cmake/plugins/CMakeLists.txt +++ b/cmake/plugins/CMakeLists.txt @@ -1,7 +1,16 @@ # $URL$ # $Id$ -add_custom_target(plugins ALL) +# create an option to exclude plugins target from ALL target +option(BUILD_PLUGINS "Build UltraStar Deluxe party-mode plugins." ON) +set(plugins_tgt_all) +if(BUILD_PLUGINS) + set(plugins_tgt_all ALL) +endif(BUILD_PLUGINS) +# create a plugins target +add_custom_target(plugins ${plugins_tgt_all}) + +# add plugins to target add_subdirectory(5000Points) add_subdirectory(Blind) add_subdirectory(Duell) diff --git a/cmake/plugins/Dont_Get_Worse/CMakeLists.txt b/cmake/plugins/Dont_Get_Worse/CMakeLists.txt index 66e6f353..5a3f6c24 100644 --- a/cmake/plugins/Dont_Get_Worse/CMakeLists.txt +++ b/cmake/plugins/Dont_Get_Worse/CMakeLists.txt @@ -1,6 +1,8 @@ # $URL$ # $Id$ pascal_add_module(hold_the_line Hold_The_Line.dpr + OUTPUT_DIR ${USDX_PLUGIN_DIR} PACKAGES sdl opengl + EXCLUDE_FROM_ALL ) add_dependencies(plugins hold_the_line) diff --git a/cmake/plugins/Duell/CMakeLists.txt b/cmake/plugins/Duell/CMakeLists.txt index ea6924ef..d1a40730 100644 --- a/cmake/plugins/Duell/CMakeLists.txt +++ b/cmake/plugins/Duell/CMakeLists.txt @@ -1,4 +1,4 @@ # $URL$ # $Id$ -pascal_add_module(duell Duell.dpr) +pascal_add_module(duell Duell.dpr OUTPUT_DIR ${USDX_PLUGIN_DIR} EXCLUDE_FROM_ALL) add_dependencies(plugins duell) diff --git a/cmake/plugins/Team_Duell/CMakeLists.txt b/cmake/plugins/Team_Duell/CMakeLists.txt index 411d0f79..7201f471 100644 --- a/cmake/plugins/Team_Duell/CMakeLists.txt +++ b/cmake/plugins/Team_Duell/CMakeLists.txt @@ -1,6 +1,8 @@ # $URL$ # $Id$ pascal_add_module(team_duell TeamDuell.dpr + OUTPUT_DIR ${USDX_PLUGIN_DIR} PACKAGES sdl opengl + EXCLUDE_FROM_ALL ) add_dependencies(plugins team_duell) diff --git a/cmake/src/CMakeLists.txt b/cmake/src/CMakeLists.txt index 1e920936..08a08197 100644 --- a/cmake/src/CMakeLists.txt +++ b/cmake/src/CMakeLists.txt @@ -10,6 +10,12 @@ add_subdirectory(lib) pascal_configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.inc.in ${CMAKE_CURRENT_BINARY_DIR}/config-${FPC_PLATFORM}.inc) +# To conform to the GNU Coding Standards, INSTALL_DATADIR is +# not hardcoded at configure-time so $prefix and $datadir can be +# changed at make-time. +# Paths cannot be passed to fpc via -d as with gcc's -D parameter. +# We use an intermediate file instead. +# See [info autoconf], "19.5 How Do I `#define' Installation Directories?" file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/paths.inc "INSTALL_DATADIR = '${CMAKE_INSTALL_PREFIX}/share/ultrastardx';") @@ -30,11 +36,11 @@ if(libprojectM_USE_CWRAPPER) endif(libprojectM_USE_CWRAPPER) pascal_add_module(ultrastardx ultrastardx.dpr - #FLAGS -vut - OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR}/../game + #FPC_FLAGS -Si -Cs2000000 # maybe set stack size? + OUTPUT_DIR ${USDX_GAME_DIR} UNITS base/*.pas - #macosx/*.pas + macosx/*.pas media/*.pas menu/*.pas screens/*.pas diff --git a/cmake/src/lib/JEDI-SDL/SDL/CMakeLists.txt b/cmake/src/lib/JEDI-SDL/SDL/CMakeLists.txt index 69c63d0a..543300c7 100644 --- a/cmake/src/lib/JEDI-SDL/SDL/CMakeLists.txt +++ b/cmake/src/lib/JEDI-SDL/SDL/CMakeLists.txt @@ -1,6 +1,15 @@ # $URL$ # $Id$ + +# Flags for the treatment of a linker issue with SDL on Mac OS X. +# Symbol _SDK_main is undefined +set(fpc_lib_flags) +if(APPLE) + set(fpc_lib_flags -k\"-U _SDL_main\") +endif(APPLE) + pascal_add_package(sdl UNITS Pas/*.pas INCLUDES Pas/*.inc + FPC_LIBRARY_FLAGS ${fpc_lib_flags} ) diff --git a/cmake/src/lib/projectM/cwrapper/CMakeLists.txt b/cmake/src/lib/projectM/cwrapper/CMakeLists.txt index acca3025..3c84736a 100644 --- a/cmake/src/lib/projectM/cwrapper/CMakeLists.txt +++ b/cmake/src/lib/projectM/cwrapper/CMakeLists.txt @@ -1,13 +1,11 @@ # $URL$ # $Id$ -if(libprojectM_USE_CWRAPPER) - include_directories(${libprojectM_INCLUDEDIR}/libprojectM) - add_definitions(-DPROJECTM_VERSION_INT=${libprojectM_VERSION_INT}) +include_directories(${libprojectM_INCLUDEDIR}/libprojectM) +add_definitions(-DPROJECTM_VERSION_INT=${libprojectM_VERSION_INT}) - set(projectm_cwrapper_srcs projectM-cwrapper.cpp) - if(WIN32) - add_library(projectM-cwrapper SHARED ${projectm_cwrapper_srcs}) - else(WIN32) - add_library(projectM-cwrapper STATIC ${projectm_cwrapper_srcs}) - endif(WIN32) -endif(libprojectM_USE_CWRAPPER) +set(projectm_cwrapper_srcs projectM-cwrapper.cpp) +if(WIN32) + add_library(projectM-cwrapper EXCLUDE_FROM_ALL SHARED ${projectm_cwrapper_srcs}) +else(WIN32) + add_library(projectM-cwrapper EXCLUDE_FROM_ALL STATIC ${projectm_cwrapper_srcs}) +endif(WIN32) diff --git a/cmake/src/switches.inc b/cmake/src/switches.inc index 215fe239..17ebd1b8 100644 --- a/cmake/src/switches.inc +++ b/cmake/src/switches.inc @@ -5,12 +5,6 @@ {$IFDEF FPC} {$H+} // use AnsiString instead of ShortString as String-type (default in Delphi) - // if -dDEBUG is specified on the command-line, FPC uses some default - // compiler-flags specified in fpc.cfg -> use -dDEBUG_MODE instead - {$IFDEF DEBUG_MODE} - {$DEFINE DEBUG} - {$ENDIF} - {$DEFINE HasInline} {$ELSE} {$DEFINE Delphi} @@ -114,4 +108,4 @@ {$DEFINE UsePortaudio} {$IFEND} -{$ENDIF PASDOC}
\ No newline at end of file +{$ENDIF PASDOC} |