diff --git a/CMakeLists.txt b/CMakeLists.txt index 22bc0e7cc..0858ecab5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,39 @@ cmake_minimum_required( VERSION 2.4 ) project(ZDoom) +# Generator expression are available some time in CMake 2.8. Due to +# cmake_minimum_required, we can assume a minor version of > 7 implies major >= 2 +if(${CMAKE_MAJOR_VERSION} GREATER 2 OR ${CMAKE_MINOR_VERSION} GREATER 7) + option( NO_GENERATOR_EXPRESSIONS "Disable generator expressions (for building pk3s with IDEs)." OFF ) +else(${CMAKE_MAJOR_VERSION} GREATER 2 OR ${CMAKE_MINOR_VERSION} GREATER 7) + set( NO_GENERATOR_EXPRESSIONS ON ) +endif(${CMAKE_MAJOR_VERSION} GREATER 2 OR ${CMAKE_MINOR_VERSION} GREATER 7) + +# Simplify pk3 building, add_pk3(filename srcdirectory) +function( add_pk3 PK3_NAME PK3_DIR ) + get_target_property(ZIPDIR_EXE zipdir LOCATION) + + # Generate target name. Just use "pk3" for main pk3 target. + string( REPLACE "." "_" PK3_TARGET ${PK3_NAME} ) + if( ${PK3_TARGET} STREQUAL "zdoom_pk3" ) + set( PK3_TARGET "pk3" ) + endif( ${PK3_TARGET} STREQUAL "zdoom_pk3" ) + + if( NO_GENERATOR_EXPRESSIONS ) + add_custom_command( OUTPUT ${ZDOOM_OUTPUT_DIR}/${PK3_NAME} + COMMAND ${ZIPDIR_EXE} -udf ${ZDOOM_OUTPUT_DIR}/${PK3_NAME} ${PK3_DIR} + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${ZDOOM_OUTPUT_DIR}/${PK3_NAME} $ + DEPENDS zipdir ${PK3_DIR} ) + else( NO_GENERATOR_EXPRESSIONS ) + add_custom_command( OUTPUT ${ZDOOM_OUTPUT_DIR}/${PK3_NAME} + COMMAND ${ZIPDIR_EXE} -udf ${ZDOOM_OUTPUT_DIR}/${PK3_NAME} ${PK3_DIR} + DEPENDS zipdir ${PK3_DIR} ) + endif( NO_GENERATOR_EXPRESSIONS ) + + add_custom_target( ${PK3_TARGET} ALL + DEPENDS ${ZDOOM_OUTPUT_DIR}/${PK3_NAME} ) +endfunction( add_pk3 ) + IF( NOT CMAKE_BUILD_TYPE ) SET( CMAKE_BUILD_TYPE Debug CACHE STRING "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel." diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index a8abc70c8..82f347fd8 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -9,7 +9,12 @@ include( CheckFunctionExists ) include( CheckCXXCompilerFlag ) include( FindPkgConfig ) -option( NO_ASM "Disable assembly code" ) +if( NOT APPLE ) + option( NO_ASM "Disable assembly code" OFF ) +else( NOT APPLE ) + # At the moment asm code doesn't work with OS X, so disable by default + option( NO_ASM "Disable assembly code" ON ) +endif( NOT APPLE ) if( "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" ) option( NO_STRIP "Do not strip Release or MinSizeRel builds" ) # At least some versions of Xcode fail if you strip with the linker diff --git a/wadsrc/CMakeLists.txt b/wadsrc/CMakeLists.txt index 422052511..83dc8292d 100644 --- a/wadsrc/CMakeLists.txt +++ b/wadsrc/CMakeLists.txt @@ -1,11 +1,3 @@ cmake_minimum_required( VERSION 2.4 ) -get_target_property(ZIPDIR_EXE zipdir LOCATION) - -add_custom_command( OUTPUT ${ZDOOM_OUTPUT_DIR}/zdoom.pk3 - COMMAND ${ZIPDIR_EXE} -udf ${ZDOOM_OUTPUT_DIR}/zdoom.pk3 ${CMAKE_CURRENT_SOURCE_DIR}/static - COMMAND ${CMAKE_COMMAND} -E copy_if_different ${ZDOOM_OUTPUT_DIR}/zdoom.pk3 $ - DEPENDS zipdir ${CMAKE_CURRENT_SOURCE_DIR}/static ) - -add_custom_target( pk3 ALL - DEPENDS ${ZDOOM_OUTPUT_DIR}/zdoom.pk3 ) +add_pk3(zdoom.pk3 ${CMAKE_CURRENT_SOURCE_DIR}/static)