CMakeLists.txt
changeset 9963 9e75dbffec81
parent 9961 c18c66d621e5
child 9965 7ced30acf533
equal deleted inserted replaced
9961:c18c66d621e5 9963:9e75dbffec81
    56 #platform specific init code
    56 #platform specific init code
    57 include(${CMAKE_MODULE_PATH}/platform.cmake)
    57 include(${CMAKE_MODULE_PATH}/platform.cmake)
    58 
    58 
    59 
    59 
    60 #when build type is not specified, assume Debug/Release according to build version information
    60 #when build type is not specified, assume Debug/Release according to build version information
    61 if (CMAKE_BUILD_TYPE)
    61 if(CMAKE_BUILD_TYPE)
    62     string (TOUPPER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE)
    62     string(TOUPPER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE)
    63     if ( NOT( (CMAKE_BUILD_TYPE MATCHES "RELEASE") OR (CMAKE_BUILD_TYPE MATCHES "DEBUG") ) )
    63     if(NOT((CMAKE_BUILD_TYPE MATCHES "RELEASE") OR
    64         set (CMAKE_BUILD_TYPE ${default_build_type} CACHE STRING "Build type (Debug/Release)" FORCE)
    64            (CMAKE_BUILD_TYPE MATCHES "DEBUG")))
    65         message (STATUS "Unknown build type, using default (${default_build_type})")
    65         set(CMAKE_BUILD_TYPE ${default_build_type} CACHE STRING "Build type (Debug/Release)" FORCE)
    66     endif ()
    66         message(STATUS "Unknown build type, using default (${default_build_type})")
    67 else (CMAKE_BUILD_TYPE)
    67     endif()
    68     set (CMAKE_BUILD_TYPE ${default_build_type} CACHE STRING "Build type (Debug/Release)" FORCE)
    68 else(CMAKE_BUILD_TYPE)
    69 endif (CMAKE_BUILD_TYPE)
    69     set(CMAKE_BUILD_TYPE ${default_build_type} CACHE STRING "Build type (Debug/Release)" FORCE)
       
    70 endif(CMAKE_BUILD_TYPE)
    70 
    71 
    71 
    72 
    72 #perform safe check that enable/disable compilation features
    73 #perform safe check that enable/disable compilation features
    73 include(${CMAKE_MODULE_PATH}/compilerchecks.cmake)
    74 include(${CMAKE_MODULE_PATH}/compilerchecks.cmake)
    74 
    75 
    79 add_flag_append(CMAKE_CXX_FLAGS "-Wall -pipe")
    80 add_flag_append(CMAKE_CXX_FLAGS "-Wall -pipe")
    80 add_flag_append(CMAKE_CXX_FLAGS_RELEASE "-O2")
    81 add_flag_append(CMAKE_CXX_FLAGS_RELEASE "-O2")
    81 add_flag_append(CMAKE_CXX_FLAGS_DEBUG "-Wextra -O0")
    82 add_flag_append(CMAKE_CXX_FLAGS_DEBUG "-Wextra -O0")
    82 
    83 
    83 #CMake adds a lot of additional configuration flags, so let's clear them up
    84 #CMake adds a lot of additional configuration flags, so let's clear them up
    84 if(${MINIMAL_FLAGS})
    85 if(MINIMAL_FLAGS)
    85     unset(CMAKE_C_FLAGS_RELEASE)
    86     unset(CMAKE_C_FLAGS_RELEASE)
    86     unset(CMAKE_C_FLAGS_DEBUG)
    87     unset(CMAKE_C_FLAGS_DEBUG)
    87     unset(CMAKE_CXX_FLAGS_RELEASE)
    88     unset(CMAKE_CXX_FLAGS_RELEASE)
    88     unset(CMAKE_CXX_FLAGS_DEBUG)
    89     unset(CMAKE_CXX_FLAGS_DEBUG)
    89 endif()
    90 endif()
    92 #parse additional parameters
    93 #parse additional parameters
    93 if(GHFLAGS)
    94 if(GHFLAGS)
    94     if(${CMAKE_VERSION} VERSION_GREATER 2.6)
    95     if(${CMAKE_VERSION} VERSION_GREATER 2.6)
    95         separate_arguments(ghflags_parsed UNIX_COMMAND ${GHFLAGS})
    96         separate_arguments(ghflags_parsed UNIX_COMMAND ${GHFLAGS})
    96     else()
    97     else()
    97         message(${WARNING} "GHFLAGS are available only when using CMake >= 2.8")
    98         message("*** GHFLAGS are available only when using CMake >= 2.8 ***")
    98     endif()
    99     endif()
    99 endif()
   100 endif()
   100 
   101 
   101 list(APPEND haskell_flags ${ghflags_parsed} "-O2")
   102 list(APPEND haskell_flags ${ghflags_parsed} "-O2")
   102 
   103 
   112                               )
   113                               )
   113 endif()
   114 endif()
   114 
   115 
   115 
   116 
   116 #lua discovery
   117 #lua discovery
   117 if (LUA_SYSTEM)
   118 if(LUA_SYSTEM)
   118     if (NOT LUA_LIBRARY OR NOT LUA_INCLUDE_DIR)
   119     if(NOT LUA_LIBRARY OR NOT LUA_INCLUDE_DIR)
   119         find_package(Lua)
   120         find_package(Lua)
   120     endif()
   121     endif()
   121 
   122 
   122     if (LUA_LIBRARY AND LUA_INCLUDE_DIR)
   123     if(LUA_LIBRARY AND LUA_INCLUDE_DIR)
   123         set(LUA_FOUND TRUE)
   124         set(LUA_FOUND TRUE)
   124         #use an IMPORTED tharget so that we can just use 'lua' to link
   125         #use an IMPORTED tharget so that we can just use 'lua' to link
   125         add_library(lua UNKNOWN IMPORTED)
   126         add_library(lua UNKNOWN IMPORTED)
   126         set_target_properties(lua PROPERTIES IMPORTED_LOCATION ${LUA_LIBRARY})
   127         set_target_properties(lua PROPERTIES IMPORTED_LOCATION ${LUA_LIBRARY})
   127     else()
   128     else()
   128         message(FATAL_ERROR "Missing Lua! Rerun cmake with -DLUA_SYSTEM=off to build the internal version")
   129         message(FATAL_ERROR "Missing Lua! Rerun cmake with -DLUA_SYSTEM=off to build the internal version")
   129     endif()
   130     endif()
   130 else()
   131 else()
   131     if (NOT LUA_LIBRARY OR NOT LUA_INCLUDE_DIR)
   132     if(NOT LUA_LIBRARY OR NOT LUA_INCLUDE_DIR)
   132         message(STATUS "LUA will be provided by the bundled sources")
   133         message(STATUS "LUA will be provided by the bundled sources")
   133     endif()
   134     endif()
   134     set(lua_output_name "hwlua")
   135     set(lua_output_name "hwlua")
   135     add_subdirectory(misc/liblua)
   136     add_subdirectory(misc/liblua)
   136 endif()
   137 endif()
   137 
   138 
   138 
   139 
   139 #physfs discovery
   140 #physfs discovery
   140 if (PHYSFS_SYSTEM)
   141 if(PHYSFS_SYSTEM)
   141     if (NOT PHYSFS_LIBRARY OR NOT PHYSFS_INCLUDE_DIR)
   142     if(NOT PHYSFS_LIBRARY OR NOT PHYSFS_INCLUDE_DIR)
   142         find_package(PhysFS)
   143         find_package(PhysFS)
   143     endif()
   144     endif()
   144 
   145 
   145     find_file(physfs_h physfs.h ${PHYSFS_INCLUDE_DIR})
   146     find_file(physfs_h physfs.h ${PHYSFS_INCLUDE_DIR})
   146     if(physfs_h)
   147     if(physfs_h)
   150         string(REGEX MATCH "([0-9]+)" physfs_majorversion "${physfs_majorversion}")
   151         string(REGEX MATCH "([0-9]+)" physfs_majorversion "${physfs_majorversion}")
   151         string(REGEX MATCH "([0-9]+)" physfs_minorversion "${physfs_minorversion}")
   152         string(REGEX MATCH "([0-9]+)" physfs_minorversion "${physfs_minorversion}")
   152         string(REGEX MATCH "([0-9]+)" physfs_patchversion "${physfs_patchversion}")
   153         string(REGEX MATCH "([0-9]+)" physfs_patchversion "${physfs_patchversion}")
   153         set(physfs_detected_ver "${physfs_majorversion}.${physfs_minorversion}.${physfs_patchversion}")
   154         set(physfs_detected_ver "${physfs_majorversion}.${physfs_minorversion}.${physfs_patchversion}")
   154 
   155 
   155         if (physfs_detected_ver VERSION_LESS "2.1.0")
   156         if(physfs_detected_ver VERSION_LESS "2.1.0")
   156             message(FATAL_ERROR "PhysFS version is too old (dected ${physfs_detected_ver}, required 2.1.0)")
   157             message(FATAL_ERROR "PhysFS version is too old (dected ${physfs_detected_ver}, required 2.1.0)")
   157             set(physfs_too_old true)
   158             set(physfs_too_old true)
   158         endif()
   159         endif()
   159     endif()
   160     endif()
   160 
   161 
   161     if (NOT PHYSFS_LIBRARY OR NOT PHYSFS_INCLUDE_DIR)
   162     if(NOT PHYSFS_LIBRARY OR NOT PHYSFS_INCLUDE_DIR)
   162         message(FATAL_ERROR "Missing PhysFS! Rerun cmake with -DPHYSFS_SYSTEM=off to build the internal version")
   163         message(FATAL_ERROR "Missing PhysFS! Rerun cmake with -DPHYSFS_SYSTEM=off to build the internal version")
   163     else()
   164     else()
   164         #use an IMPORTED tharget so that we can just use 'physfs' to link
   165         #use an IMPORTED tharget so that we can just use 'physfs' to link
   165         add_library(physfs UNKNOWN IMPORTED)
   166         add_library(physfs UNKNOWN IMPORTED)
   166         set_target_properties(physfs PROPERTIES IMPORTED_LOCATION ${PHYSFS_LIBRARY})
   167         set_target_properties(physfs PROPERTIES IMPORTED_LOCATION ${PHYSFS_LIBRARY})
   167     endif()
   168     endif()
   168 else()
   169 else()
   169     if (NOT PHYSFS_LIBRARY OR NOT PHYSFS_INCLUDE_DIR)
   170     if(NOT PHYSFS_LIBRARY OR NOT PHYSFS_INCLUDE_DIR)
   170         message(STATUS "PhysFS will be provided by the bundled sources")
   171         message(STATUS "PhysFS will be provided by the bundled sources")
   171     endif()
   172     endif()
   172     set(physfs_output_name "hwphysfs")
   173     set(physfs_output_name "hwphysfs")
   173     add_subdirectory(misc/libphysfs)
   174     add_subdirectory(misc/libphysfs)
   174 endif()
   175 endif()