Commit dba195d5 authored by Philip Trettner's avatar Philip Trettner

CMakeLists.txt is now a modern-cmake alternative to CMakeListsStaticInclude...

CMakeLists.txt is now a modern-cmake alternative to CMakeListsStaticInclude and builds a simple, static lib
parent edd60244
#
# Use this to compile ACGL as a library. To include it statically compiled into
# Use this to compile ACGL as a library. To include it statically compiled into
# your own project you can also just include the CMakeListsStaticInclude.txt:
# INCLUDE(${CMAKE_CURRENT_SOURCE_DIR}/CMakeListsStaticInclude.txt)
#
CMAKE_MINIMUM_REQUIRED (VERSION 2.6)
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/CMakeMacros.txt)
CMAKE_MINIMUM_REQUIRED (VERSION 3.0)
################################################################################
# Global Settings
################################################################################
# Name of the Project
# Name of the Project
PROJECT(ACGL)
INCLUDE(${CMAKE_CURRENT_SOURCE_DIR}/cmake/CompileOptions.txt)
# Specify dependencies
SET(NEED_ACGL_GLOBAL_EXTERN_DIR TRUE)
INCLUDE(${CMAKE_CURRENT_SOURCE_DIR}/cmake/GlobalAndLocalExternACGL.txt)
# OpenGL Support
IF(NOT DEFINED ACGL_OPENGL_SUPPORT)
......@@ -31,55 +24,29 @@ IF(NOT DEFINED ACGL_ERROR_LEVEL)
SET_PROPERTY(CACHE ACGL_ERROR_LEVEL PROPERTY STRINGS EC0 EC1 EC2 EC3)
ENDIF()
# UseQT
IF(NOT DEFINED ACGL_COMPILE_WITH_QT)
SET(ACGL_COMPILE_WITH_QT Yes CACHE STRING "")
SET_PROPERTY(CACHE ACGL_COMPILE_WITH_QT PROPERTY STRINGS Yes No)
# Build Type (Debug, Release, Deploy, ...)
IF(NOT CMAKE_BUILD_TYPE)
SET(CMAKE_BUILD_TYPE Release CACHE STRING "" FORCE)
ENDIF()
################################################################################
# Basic Configuration
################################################################################
# Where to find the cmake finders?
SET(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})
# Target directory
SET(LIBRARY_OUTPUT_PATH "${CMAKE_CURRENT_SOURCE_DIR}/lib")
SET_PROPERTY(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS Release Debug Deploy)
################################################################################
# Project Files
################################################################################
#
# if ACGL should not get compiled as a library, just include the following file
# if ACGL should not get compiled as a library, just include the following file
# into the projects CMakeList.txt
#
SET(ACGL_SKIP_INCLUDE_AND_DEF TRUE) # don't use include_directories and add_definitions for modern cmake
INCLUDE(${CMAKE_CURRENT_SOURCE_DIR}/CMakeListsStaticInclude.txt)
################################################################################
# Defines
################################################################################
INCLUDE(${CMAKE_CURRENT_SOURCE_DIR}/cmake/DefinesACGL.txt)
ADD_DEFINITIONS(${ACGL_DEFINES})
################################################################################
# External Libraries
################################################################################
# Qt
IF(ACGL_COMPILE_WITH_QT)
#MESSAGE("QT")
SET(QT_USE_QTOPENGL TRUE)
FIND_PACKAGE(Qt4 REQUIRED)
INCLUDE(${QT_USE_FILE})
SET(LIBRARIES ${LIBRARIES} ${QT_LIBRARIES})
ENDIF()
# Define the Project, add all required sources and dependencies to it
ADD_LIBRARY(ACGL STATIC ${SOURCE_FILES} ${HEADER_FILES})
# static linking for MSVC
IF(ACGL_STATIC_RUNTIME_ENV)
if(MSVC)
if(MSVC)
foreach(flag
CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE
CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO)
......@@ -91,17 +58,33 @@ if(MSVC)
ENDIF()
################################################################################
# Final Definition
# Target setup
################################################################################
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -stdlib=libc++")
elseif(CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
elseif(MSVC)
# Include directories
target_include_directories(ACGL PUBLIC
include/
)
# Compile flags
target_compile_options(ACGL PUBLIC
$<$<COMPILE_LANGUAGE:CXX>:-std=c++11> # C++11 for C++ files
)
# WIN32 define
IF(WIN32)
target_compile_definitions(ACGL PUBLIC WIN32)
ENDIF(WIN32)
# DEBUG define
string(TOLOWER ${CMAKE_BUILD_TYPE} BuildTypeLower)
if(BuildTypeLower STREQUAL debug)
target_compile_definitions(ACGL PUBLIC DEBUG)
endif()
# Define the Project, add all required sources and dependencies to it
ADD_LIBRARY(ACGL${COMPILE_POSTFIX} STATIC ${SOURCE_FILES} ${HEADER_FILES})
TARGET_LINK_LIBRARIES(ACGL${COMPILE_POSTFIX} ${LIBRARIES})
#MESSAGE(${LIBRARY_NAME})
# OpenGL define
if(${ACGL_OPENGL_SUPPORT} MATCHES "CORE_")
target_compile_definitions(ACGL PUBLIC ACGL_OPENGL_PROFILE_CORE)
endif()
string(REGEX MATCH "([0-9]+)" ACGL_OPENGL_VERSION ${ACGL_OPENGL_SUPPORT})
target_compile_definitions(ACGL PUBLIC ACGL_OPENGL_VERSION_${ACGL_OPENGL_VERSION})
......@@ -40,19 +40,21 @@ RECURSE_GROUPS ("${ACGL_BASE_DIR}/src")
SET(HEADER_FILES ${HEADER_FILES} ${HEADER_FILES_H} ${HEADER_FILES_HH} ${HEADER_FILES_HPP})
SET(SOURCE_FILES ${SOURCE_FILES} ${SOURCE_FILES_C} ${SOURCE_FILES_CC} ${SOURCE_FILES_CPP})
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_LIST_DIR}/include)
# set debug build with: cmake -DCMAKE_BUILD_TYPE=Debug ...
IF(CMAKE_BUILD_TYPE MATCHES Debug)
ADD_DEFINITIONS(-DDEBUG)
ENDIF(CMAKE_BUILD_TYPE MATCHES Debug)
IF(CMAKE_BUILD_TYPE MATCHES debug)
ADD_DEFINITIONS(-DDEBUG)
ENDIF(CMAKE_BUILD_TYPE MATCHES debug)
IF(CMAKE_BUILD_TYPE MATCHES DEBUG)
ADD_DEFINITIONS(-DDEBUG)
ENDIF(CMAKE_BUILD_TYPE MATCHES DEBUG)
IF(WIN32)
ADD_DEFINITIONS(-DWIN32)
ENDIF(WIN32)
IF(NOT ACGL_SKIP_INCLUDE_AND_DEF)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_LIST_DIR}/include)
# set debug build with: cmake -DCMAKE_BUILD_TYPE=Debug ...
IF(CMAKE_BUILD_TYPE MATCHES Debug)
ADD_DEFINITIONS(-DDEBUG)
ENDIF(CMAKE_BUILD_TYPE MATCHES Debug)
IF(CMAKE_BUILD_TYPE MATCHES debug)
ADD_DEFINITIONS(-DDEBUG)
ENDIF(CMAKE_BUILD_TYPE MATCHES debug)
IF(CMAKE_BUILD_TYPE MATCHES DEBUG)
ADD_DEFINITIONS(-DDEBUG)
ENDIF(CMAKE_BUILD_TYPE MATCHES DEBUG)
IF(WIN32)
ADD_DEFINITIONS(-DWIN32)
ENDIF(WIN32)
ENDIF()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment