CMakeLists.txt 4.28 KB
Newer Older
1
2
3
#
# 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:
4
# INCLUDE(${CMAKE_CURRENT_SOURCE_DIR}/CMakeListsStaticInclude.txt)
5
#
Robert Menzel's avatar
Robert Menzel committed
6
7
CMAKE_MINIMUM_REQUIRED (VERSION 2.6) 

8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
################################################################################
# Macro to sort acgl into directories
################################################################################

MACRO (RECURSE_GROUPS dirname)
    FILE(GLOB_RECURSE allfiles "${dirname}/*.*")
    SET(ALL_FILES ${ALL_FILES} ${allfiles})
    STRING(REGEX REPLACE ".*/([^/]*)" "\\1" maindir "${dirname}")

    FOREACH(file ${allfiles})
        STRING(REGEX REPLACE "${dirname}/(.*)/[^/]*" "\\1" loopdirname "${file}")
        STRING(REGEX REPLACE "/" "\\\\" loopdirname "${loopdirname}")

        IF(NOT "${file}" MATCHES "${dirname}/(.*)/[^/]*")
            source_group("${maindir}" FILES  ${file})
        ELSE()
            source_group("${maindir}\\${loopdirname}" FILES  ${file})
        ENDIF()
    ENDFOREACH()
ENDMACRO (RECURSE_GROUPS)

Robert Menzel's avatar
Robert Menzel committed
29
30
31
32
33
34
################################################################################
# Global Settings
################################################################################

# Name of the Project 
PROJECT(ACGL)
35
INCLUDE(${CMAKE_CURRENT_SOURCE_DIR}/cmake/CompileOptions.txt)
Robert Menzel's avatar
Robert Menzel committed
36
37
38

# Specify dependencies
SET(NEED_ACGL_GLOBAL_EXTERN_DIR TRUE)
39
INCLUDE(${CMAKE_CURRENT_SOURCE_DIR}/cmake/GlobalAndLocalExternACGL.txt)
Robert Menzel's avatar
Robert Menzel committed
40
41

# OpenGL Support
42
43
IF(NOT DEFINED ACGL_OPENGL_SUPPORT)
    SET(ACGL_OPENGL_SUPPORT CORE_42 CACHE STRING "")
44
    SET_PROPERTY(CACHE ACGL_OPENGL_SUPPORT PROPERTY STRINGS CORE_32 CORE_33 CORE_40 CORE_41 CORE_42 CORE_43 CORE_42 FULL_21 FULL_30 FULL_31 FULL_32 FULL_33 FULL_40 FULL_41 FULL_42 FULL_43 ES_20)
45
ENDIF()
Robert Menzel's avatar
Robert Menzel committed
46

47
48
49
50
51
# Error Level
IF(NOT DEFINED ACGL_ERROR_LEVEL)
    SET(ACGL_ERROR_LEVEL EC0 CACHE STRING "")
    SET_PROPERTY(CACHE ACGL_ERROR_LEVEL PROPERTY STRINGS EC0 EC1 EC2 EC3)
ENDIF()
Robert Menzel's avatar
Robert Menzel committed
52

53
54
55
56
# 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)
Robert Menzel's avatar
Robert Menzel committed
57
58
ENDIF()

59
60
61
62
63
################################################################################
# Basic Configuration
################################################################################

# Where to find the cmake finders?
64
SET(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})
65
66
67
68
69
70
71

# Target directory
SET(LIBRARY_OUTPUT_PATH "${CMAKE_CURRENT_SOURCE_DIR}/lib")

################################################################################
# Project Files
################################################################################
Robert Menzel's avatar
Robert Menzel committed
72

73
74
75
76
#
# if ACGL should not get compiled as a library, just include the following file 
# into the projects CMakeList.txt
#
Janis Born's avatar
Janis Born committed
77
INCLUDE(${CMAKE_CURRENT_SOURCE_DIR}/CMakeListsStaticInclude.txt)
Robert Menzel's avatar
Robert Menzel committed
78

79
80
81
################################################################################
# Defines
################################################################################
Robert Menzel's avatar
Robert Menzel committed
82

83
INCLUDE(${CMAKE_CURRENT_SOURCE_DIR}/cmake/DefinesACGL.txt)
Lars Krecklau's avatar
Lars Krecklau committed
84
ADD_DEFINITIONS(${ACGL_DEFINES})
Robert Menzel's avatar
Robert Menzel committed
85

86
87
88
################################################################################
# External Libraries
################################################################################
Robert Menzel's avatar
Robert Menzel committed
89

90
# Qt
91
IF(ACGL_COMPILE_WITH_QT)
92
    #MESSAGE("QT")
Robert Menzel's avatar
Robert Menzel committed
93
94
95
96
    SET(QT_USE_QTOPENGL TRUE)
    FIND_PACKAGE(Qt4 REQUIRED)
    INCLUDE(${QT_USE_FILE})
    SET(LIBRARIES ${LIBRARIES} ${QT_LIBRARIES})
97
ENDIF()
Robert Menzel's avatar
Robert Menzel committed
98

99
100
101
102
103
104
105
106
107
108
109
110
111
# static linking for MSVC
IF(ACGL_STATIC_RUNTIME_ENV)
if(MSVC)
        foreach(flag
                CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE
                CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO)
            if(${flag} MATCHES "/MD")
                string(REGEX REPLACE "/MD" "/MT" ${flag} "${${flag}}")
            endif()
        endforeach()
    endif()
ENDIF()

112
113
114
################################################################################
# Final Definition
################################################################################
Robert Menzel's avatar
Robert Menzel committed
115

116
# Define the Project, add all required sources and dependencies to it
Lars Krecklau's avatar
Lars Krecklau committed
117
118
ADD_LIBRARY(ACGL${COMPILE_POSTFIX} STATIC ${SOURCE_FILES} ${HEADER_FILES})
TARGET_LINK_LIBRARIES(ACGL${COMPILE_POSTFIX} ${LIBRARIES})
119
#MESSAGE(${LIBRARY_NAME})