Update cmake files

pull/200/head
Hleb Valoshka 2019-01-10 20:55:18 +03:00
parent 379a658dff
commit 45e6a61bcf
4 changed files with 108 additions and 24 deletions

View File

@ -29,19 +29,10 @@ if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Build type." FORCE)
endif()
#string(REPLACE " -fpermissive" "" CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}")
#string(REPLACE "-O3" "-O2" CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}")
set(CMAKE_INCLUDE_CURRENT_DIR ON)
add_compile_options(-fPIC)
#temporary
add_compile_options(-g)
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(APPLE true)
if(NOT MSVC)
add_compile_options(-fPIC)
endif()
if(UNIX AND (NOT APPLE) AND (NOT CYGWIN))
@ -50,7 +41,7 @@ endif()
# Theora supported on Unix-like systems only, but not on OSX
if(NOT _UNIX)
set(ENABLE_THEORA OFF CACHE)
set(ENABLE_THEORA OFF)
endif()
# _USE_MATH_DEFINES enables use of math constants like M_PI,
@ -61,10 +52,18 @@ add_definitions(-D_USE_MATH_DEFINES)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_C_STANDARD 11)
# Use our cmake files
list(INSERT CMAKE_MODULE_PATH 0 "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
include(GNUInstallDirs)
include(CheckIncludeFiles)
include(cmake/rpath.cmake)
include(cmake/cotire.cmake)
include(rpath)
if (NOT MSVC)
include(cotire)
else()
macro(cotire _target)
endmacro()
endif()
#
# NLS (Gettext) support
@ -74,27 +73,36 @@ if(ENABLE_NLS)
if(NOT GETTEXT_FOUND)
message(WARNING "Gettext is not found, traslations won't be created.")
endif()
include(cmake/FixGettext.cmake)
include(FixGettext)
include(FindIntl)
find_package(Intl REQUIRED)
include_directories(${Intl_INCLUDE_DIRS})
link_libraries(${Intl_LIBRARIES})
endif()
if(_UNIX)
find_package(PkgConfig)
endif()
if(ENABLE_THEORA)
if(_UNIX AND ENABLE_THEORA)
pkg_search_module(THEORA theora REQUIRED)
include_directories(${THEORA_INCLUDE_DIRS})
link_libraries(${THEORA_LIBRARIES})
add_definitions(-DTHEORA)
endif()
if (WIN32)
link_libraries("vfw32" "comctl32" "winmm")
endif()
find_package(OpenGL REQUIRED)
include_directories(${OPENGL_INCLUDE_DIRS})
link_libraries(${OPENGL_LIBRARIES})
find_package(GLEW)
if(GLEW_FOUND)
#link_libraries(GLEW::GLEW)
link_libraries(GLEW::GLEW)
include_directories(${GLEW_INCLUDE_DIRS})
link_libraries(${GLEW_LIBRARIES})
find_package(OpenGL)
@ -203,14 +211,27 @@ if(ENABLE_SPICE)
add_definitions(-DUSE_SPICE)
endif()
if(WIN32)
add_definitions(-D_CRT_SECURE_NO_WARNINGS -D_SCL_SECURE_NO_WARNINGS)
add_definitions(-DNOMINMAX -DWIN32_LEAN_AND_MEAN)
add_definitions(-DWINVER=0x0601 -D_WIN32_WINNT=0x0601)
endif()
set(DATADIR "${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}")
set(FULL_DATADIR "${CMAKE_INSTALL_FULL_DATADIR}/${PROJECT_NAME}")
execute_process(
COMMAND git log --pretty=format:"%h" -1
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
OUTPUT_VARIABLE GIT_COMMIT
)
if (NOT GIT_COMMIT)
find_program(GIT_FOUND git)
if (GIT_FOUND)
execute_process(
COMMAND git log --pretty=format:"%h" -1
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
OUTPUT_VARIABLE GIT_COMMIT
)
else()
set(GIT_COMMIT "unknown")
endif()
endif()
add_definitions(
-DVERSION="${VERSION}"

View File

@ -0,0 +1,59 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
#.rst:
# FindIntl
# --------
#
# Find the Gettext libintl headers and libraries.
#
# This module reports information about the Gettext libintl
# installation in several variables. General variables::
#
# Intl_FOUND - true if the libintl headers and libraries were found
# Intl_INCLUDE_DIRS - the directory containing the libintl headers
# Intl_LIBRARIES - libintl libraries to be linked
#
# The following cache variables may also be set::
#
# Intl_INCLUDE_DIR - the directory containing the libintl headers
# Intl_LIBRARY - the libintl library (if any)
#
# .. note::
# On some platforms, such as Linux with GNU libc, the gettext
# functions are present in the C standard library and libintl
# is not required. ``Intl_LIBRARIES`` will be empty in this
# case.
#
# .. note::
# If you wish to use the Gettext tools (``msgmerge``,
# ``msgfmt``, etc.), use :module:`FindGettext`.
# Written by Roger Leigh <rleigh@codelibre.net>
# Find include directory
find_path(Intl_INCLUDE_DIR
NAMES "libintl.h"
DOC "libintl include directory")
mark_as_advanced(Intl_INCLUDE_DIR)
# Find all Intl libraries
find_library(Intl_LIBRARY
NAMES "intl" "libintl"
DOC "libintl libraries (if not in the C library)")
mark_as_advanced(Intl_LIBRARY)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Intl
FOUND_VAR Intl_FOUND
REQUIRED_VARS Intl_INCLUDE_DIR
FAIL_MESSAGE "Failed to find Gettext libintl")
if(Intl_FOUND)
set(Intl_INCLUDE_DIRS "${Intl_INCLUDE_DIR}")
if(Intl_LIBRARY)
set(Intl_LIBRARIES "${Intl_LIBRARY}")
else()
unset(Intl_LIBRARIES)
endif()
endif()

View File

@ -13,5 +13,7 @@ foreach(lib ${CELESTIA_LIBS} tools)
add_subdirectory(${lib})
endforeach()
add_executable(buildstardb buildstardb.cpp)
cotire(buildstardb)
if (NOT WIN32)
add_executable(buildstardb buildstardb.cpp)
cotire(buildstardb)
endif()

View File

@ -1 +1,3 @@
if (NOT WIN32)
add_subdirectory(stardb)
endif()