CMakeLists.txt
changeset 11659 71bdf987e41f
parent 11654 870f22de388b
child 11699 83c40c1eb0e7
child 11701 e71435e046a1
equal deleted inserted replaced
11658:f87ed83568c8 11659:71bdf987e41f
    48 if(UNIX AND NOT APPLE)
    48 if(UNIX AND NOT APPLE)
    49     set(DATA_INSTALL_DIR "share/hedgewars" CACHE STRING "Resource folder path")
    49     set(DATA_INSTALL_DIR "share/hedgewars" CACHE STRING "Resource folder path")
    50 endif()
    50 endif()
    51 
    51 
    52 option(NOVERSIONINFOUPDATE "Disable update of version_info.txt. To be used if source is in a git/repo that is NOT the hedgewars repo" OFF)
    52 option(NOVERSIONINFOUPDATE "Disable update of version_info.txt. To be used if source is in a git/repo that is NOT the hedgewars repo" OFF)
       
    53 
       
    54 
       
    55 if(BUILD_ENGINE_JS)
       
    56     if(NOT CMAKE_TOOLCHAIN_FILE)
       
    57         message(FATAL_ERROR "Missing emscripten toolchain file\nRerun cmake with -DCMAKE_TOOLCHAIN_FILE=${CMAKE_SOURCE_DIR}/cmake_modules/Platform/Emscripten.cmake")
       
    58     endif()
       
    59 
       
    60     set(BUILD_ENGINE_C ON CACHE STRING "Required for BUILD_ENGINE_JS" FORCE)
       
    61     set(NOAUTOUPDATE ON CACHE STRING "Required for BUILD_ENGINE_JS" FORCE)
       
    62     set(PHYSFS_SYSTEM OFF CACHE STRING "Required for BUILD_ENGINE_JS" FORCE)
       
    63     set(LUA_SYSTEM OFF CACHE STRING "Required for BUILD_ENGINE_JS" FORCE)
       
    64     set(NOVIDEOREC ON CACHE STRING "Required for BUILD_ENGINE_JS" FORCE)
       
    65     set(NOSERVER ON CACHE STRING "Required for BUILD_ENGINE_JS" FORCE)
       
    66     set(GL2 ON CACHE STRING "Required for BUILD_ENGINE_JS" FORCE)
       
    67     set(BUILD_SHARED_LIBS OFF CACHE STRING "Required for BUILD_ENGINE_JS" FORCE)
       
    68 endif()
    53 
    69 
    54 #system paths for finding required fonts (see share/hedgewars/Data/fonts)
    70 #system paths for finding required fonts (see share/hedgewars/Data/fonts)
    55 #subdirectories will NOT be searched.
    71 #subdirectories will NOT be searched.
    56 #all fonts that can't be found will be bundled with hedgewars
    72 #all fonts that can't be found will be bundled with hedgewars
    57 set(FONTS_DIRS "" CACHE STRING "Additional paths to folders where required fonts can be found ( ; is separator)")
    73 set(FONTS_DIRS "" CACHE STRING "Additional paths to folders where required fonts can be found ( ; is separator)")
    89     set(CMAKE_BUILD_TYPE ${default_build_type} CACHE STRING "Build type (Debug/Release/RelWithDebInfo)" FORCE)
   105     set(CMAKE_BUILD_TYPE ${default_build_type} CACHE STRING "Build type (Debug/Release/RelWithDebInfo)" FORCE)
    90 endif(CMAKE_BUILD_TYPE)
   106 endif(CMAKE_BUILD_TYPE)
    91 
   107 
    92 
   108 
    93 #perform safe check that enable/disable compilation features
   109 #perform safe check that enable/disable compilation features
    94 include(${CMAKE_MODULE_PATH}/compilerchecks.cmake)
   110 #skip when crosscompiling to javascript
       
   111 if(NOT BUILD_ENGINE_JS)
       
   112     include(${CMAKE_MODULE_PATH}/compilerchecks.cmake)
       
   113 endif()
    95 
   114 
    96 #set default compiler flags
   115 #set default compiler flags
    97 add_flag_append(CMAKE_C_FLAGS "-Wall -pipe")
   116 add_flag_append(CMAKE_C_FLAGS "-Wall -pipe")
    98 add_flag_append(CMAKE_C_FLAGS_RELEASE "-O2")
   117 add_flag_append(CMAKE_C_FLAGS_RELEASE "-O2")
    99 add_flag_append(CMAKE_C_FLAGS_DEBUG "-Wextra -O0")
   118 add_flag_append(CMAKE_C_FLAGS_DEBUG "-Wextra -O0")
   134                               )
   153                               )
   135 endif()
   154 endif()
   136 
   155 
   137 
   156 
   138 #build engine without freepascal
   157 #build engine without freepascal
   139 if(BUILD_ENGINE_C)
   158 if(BUILD_ENGINE_C AND NOT BUILD_ENGINE_JS)
   140     find_package(Clang REQUIRED)
   159     find_package(Clang REQUIRED)
   141 
   160 
   142     if(${CLANG_VERSION} VERSION_LESS "3.0")
   161     if(${CLANG_VERSION} VERSION_LESS "3.0")
   143         message(FATAL_ERROR "LLVM/Clang compiler required version is 3.0 but version ${CLANG_VERSION} was found!")
   162         message(FATAL_ERROR "LLVM/Clang compiler required version is 3.0 but version ${CLANG_VERSION} was found!")
   144     endif()
   163     endif()
   224     add_subdirectory(tools/pas2c)
   243     add_subdirectory(tools/pas2c)
   225     add_subdirectory(project_files/hwc)
   244     add_subdirectory(project_files/hwc)
   226 else()
   245 else()
   227     #main pascal engine
   246     #main pascal engine
   228     add_subdirectory(hedgewars)
   247     add_subdirectory(hedgewars)
   229     if(BUILD_ENGINE_JS)
       
   230         message(FATAL_ERROR "This option needs BUILD_ENGINE_C to be set")
       
   231     endif()
       
   232 endif()
   248 endif()
   233 
   249 
   234 #Android related build scripts
   250 #Android related build scripts
   235 #TODO: when ANDROID, BUILD_ENGINE_LIBRARY should be set
   251 #TODO: when ANDROID, BUILD_ENGINE_LIBRARY should be set
   236 if(ANDROID)
   252 if(ANDROID)
   237     add_subdirectory(project_files/Android-build)
   253     add_subdirectory(project_files/Android-build)
   238 else(ANDROID)
   254 else(ANDROID)
       
   255     #skip frontend for javascript
       
   256     if(NOT BUILD_ENGINE_JS)
       
   257         add_subdirectory(QTfrontend)
       
   258         add_subdirectory(share)
       
   259     endif()
       
   260 
   239     add_subdirectory(bin)
   261     add_subdirectory(bin)
   240     add_subdirectory(QTfrontend)
       
   241     add_subdirectory(share)
       
   242     add_subdirectory(tools)
   262     add_subdirectory(tools)
   243 endif(ANDROID)
   263 endif(ANDROID)
   244 
   264 
   245 include(${CMAKE_MODULE_PATH}/cpackvars.cmake)
   265 include(${CMAKE_MODULE_PATH}/cpackvars.cmake)
   246 
   266