onilink_

Untitled

Sep 27th, 2021
4,836
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # cmake -DCMAKE_BUILD_TYPE=release -G"MinGW Makefiles"
  2. # cmake -DCMAKE_BUILD_TYPE=release -G"Unix Makefiles"
  3. # cmake .
  4. cmake_minimum_required(VERSION 3.0.0)
  5.  
  6. project(planet_centauri)
  7.  
  8. # Set configuration in release by default
  9. if( NOT CMAKE_BUILD_TYPE )
  10.   set( CMAKE_BUILD_TYPE "Release"
  11.        CACHE STRING "Build configuration 'Release' or 'Debug'."
  12.        FORCE )
  13. endif()
  14.  
  15. if( NOT DEBUG_EXT )
  16.   set( DEBUG_EXT 0 )
  17. endif()
  18.  
  19. message(STATUS ${CMAKE_C_COMPILER_VERSION})
  20. message(STATUS ${CMAKE_CXX_COMPILER_VERSION})
  21.  
  22. # optimize build time
  23. #set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fuse-ld=lld")
  24.  
  25. # Set C++ flags
  26. string(APPEND CMAKE_CXX_FLAGS " -std=c++14")
  27. string(APPEND CMAKE_CXX_FLAGS " -Wall")
  28. string(APPEND CMAKE_CXX_FLAGS " -Wextra")
  29. #string(APPEND CMAKE_CXX_FLAGS " -Weffc++")
  30. string(APPEND CMAKE_CXX_FLAGS " -Wfatal-errors")
  31. string(APPEND CMAKE_CXX_FLAGS " -pedantic")
  32. string(APPEND CMAKE_CXX_FLAGS " -Wno-unused-parameter")
  33. string(APPEND CMAKE_CXX_FLAGS " -Wno-missing-braces")
  34. string(APPEND CMAKE_CXX_FLAGS " -Wno-sign-compare")
  35. string(APPEND CMAKE_CXX_FLAGS " -Werror=return-type")
  36. string(APPEND CMAKE_CXX_FLAGS " -ftemplate-depth=3000")
  37.  
  38. #string(APPEND CMAKE_CXX_FLAGS_DEBUG " -O0")
  39. string(APPEND CMAKE_CXX_FLAGS_DEBUG " -Og")
  40. string(APPEND CMAKE_CXX_FLAGS_DEBUG " -ggdb")
  41. string(APPEND CMAKE_CXX_FLAGS_DEBUG " -fsanitize=undefined,address")
  42. string(APPEND CMAKE_CXX_FLAGS_DEBUG " -fno-omit-frame-pointer")
  43. string(APPEND CMAKE_CXX_FLAGS_DEBUG " -pg")
  44.  
  45. if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
  46.     string(APPEND CMAKE_CXX_FLAGS_RELEASE " -s")
  47. endif()
  48.  
  49. #string(APPEND CMAKE_CXX_FLAGS_RELEASE " -gstabs") # for stack_trace
  50. string(APPEND CMAKE_CXX_FLAGS_RELEASE " -O2")
  51.  
  52. if( DEBUG_EXT )
  53.     string(APPEND CMAKE_CXX_FLAGS_DEBUG " -D_GLIBCXX_DEBUG")
  54. endif()
  55.  
  56. include_directories(AFTER .)
  57.  
  58. #if(UNIX)
  59.   #set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -static-libgcc -static-libstdc++")
  60.   #set(CMAKE_SKIP_BUILD_RPATH FALSE)
  61.   #set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
  62.   #set(CMAKE_INSTALL_RPATH "./lib")
  63.   #set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
  64. #endif()
  65.  
  66. # Linux specific definitions
  67. if(UNIX AND NOT APPLE)
  68.   #add_definitions(-Wl,-rpath=./lib)
  69.   #set(CMAKE_INSTALL_RPATH "$ORIGIN/../lib/linux64:$ORIGIN/")
  70.  
  71.   if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
  72.       set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Wl,-rpath=./lib/linux64")
  73.   endif()
  74.   link_directories(./lib/linux64)
  75. endif()
  76.  
  77. # OSX specific definitions
  78. if(UNIX AND APPLE)
  79.   link_directories(./lib/osx32)
  80. endif()
  81.  
  82. # Windows specific definitions
  83. if(WIN32)
  84.   string(APPEND CMAKE_CXX_FLAGS_RELEASE " -mwindows")
  85.   include_directories(AFTER ./include/win32)
  86.   link_directories(./lib/win32)
  87. endif()
  88.  
  89. # OniDev2 setup
  90. include_directories(AFTER ../OniDev2/project/include)
  91.  
  92. if( DEBUG_EXT )
  93.   link_directories(../BuildOniDev2DebugExt/lib/)
  94. elseif( CMAKE_BUILD_TYPE EQUAL "Debug" )
  95.   link_directories(../BuildOniDev2Debug/lib/)
  96. else() # Release
  97.   link_directories(../BuildOniDev2Release/lib/)
  98. endif()
  99.  
  100. # Import project files
  101. file(GLOB_RECURSE SOURCE_FILES ./*.hpp ./*.h ./*.cpp ./*.c)
  102.  
  103. # Windows, MinGW - Set executable icon file
  104. set(RES_FILES "")
  105. if(MINGW)
  106.   set(RES_FILES resource.rc)
  107.   set(CMAKE_RC_COMPILER_INIT windres)
  108.   ENABLE_LANGUAGE(RC)
  109.   SET(CMAKE_RC_COMPILE_OBJECT "<CMAKE_RC_COMPILER> <FLAGS> -O coff <DEFINES> -i <SOURCE> -o <OBJECT>")
  110. endif()
  111.  
  112. add_executable(PlanetCentauri ${SOURCE_FILES} ${RES_FILES})
  113.  
  114. find_package(OpenGL REQUIRED)
  115. find_package(OpenAL REQUIRED)
  116. find_package(Freetype REQUIRED)
  117. find_package(Threads REQUIRED)
  118.  
  119. if(NOT WIN32)
  120.     find_package(SDL2 REQUIRED)
  121. endif()
  122.  
  123. set(FOUND_INCLUDES
  124.         ${FREETYPE_INCLUDE_DIRS}
  125.         ${OPENGL_INCLUDE_DIR}
  126.         ${OPENAL_INCLUDE_DIR}
  127. )
  128.  
  129. set(FOUND_LIBS
  130.         onidev steam_api
  131.         ${FREETYPE_LIBRARIES}
  132.         ${OPENGL_gl_LIBRARY}
  133.         ${OPENGL_glu_LIBRARY}
  134.         ${OPENAL_LIBRARY}
  135.         ${CMAKE_THREAD_LIBS_INIT}
  136. )
  137.  
  138. if(WIN32)
  139.     set(FOUND_LIBS ${FOUND_LIBS} ws2_32 wsock32 winmm gdi32 user32 kernel32)
  140.     set(FOUND_LIBS ${FOUND_LIBS} sdl2 zlibstatic SteamWrapper liblua_static)
  141. else()
  142.     set(FOUND_INCLUDES ${FOUND_INCLUDES} ${SDL2_INCLUDE_DIRS})
  143.     set(FOUND_LIBS ${FOUND_LIBS} SDL2 z stdc++ m dl lua5.1)
  144. endif()
  145.  
  146. #if(UNIX AND NOT APPLE)
  147. #    set(FOUND_LIBS ${FOUND_LIBS} X11)
  148. #endif()
  149.  
  150. include_directories(AFTER ${FOUND_INCLUDES})
  151.  
  152. target_link_libraries(PlanetCentauri
  153.         ${FOUND_LIBS}
  154. )
  155.  
  156.  
RAW Paste Data