CMakeLists.txt 5.1 KB
Newer Older
Timothee Habra's avatar
Timothee Habra committed
1
2
3
4
# Copyright: (C)
# Authors: Timothee Habra
# CopyPolicy: Released under the terms of the LGPLv2.1 or later, see LGPL.TXT

5
cmake_minimum_required(VERSION 2.8.7)
Timothee Habra's avatar
Timothee Habra committed
6
7
8

project(MBsysC_realtime)

9
10
11
12
13
14
15
# project configuration
set( CMAKE_C_FLAGS_RELEASE   "-O3" )
set( CMAKE_CXX_FLAGS_RELEASE "-O3" )

# release of debug
release_debug()

Timothee Habra's avatar
Timothee Habra committed
16
17
# list source files to compile
init_src()
18
19
increment_src( ${PROJECT_SOURCE_DIR}/realtime )
increment_src( ${PROJECT_SOURCE_DIR}/void )
Timothee Habra's avatar
Timothee Habra committed
20
21
22
23

# Get SDL lib and add plot functions to src
if (FLAG_PLOT)

Nicolas Van der Noot's avatar
Nicolas Van der Noot committed
24
25
26
27
    # Find SDL
    sdl_lib(mbs_realtime)
    set(SDL2_LIBRARIES ${SDL2_LIBRARIES} PARENT_SCOPE)
    set(SDL2TTF_LIBRARIES ${SDL2TTF_LIBRARIES} PARENT_SCOPE)
Timothee Habra's avatar
Timothee Habra committed
28

29
    increment_src( ${PROJECT_SOURCE_DIR}/sdl )
Timothee Habra's avatar
Timothee Habra committed
30

Nicolas Van der Noot's avatar
Nicolas Van der Noot committed
31
32
    # configure a header file to pass some of the CMake settings to the source code
    set(SDL_FILES ${CMAKE_CURRENT_SOURCE_DIR}/sdl/SDL_files)
Timothee Habra's avatar
Timothee Habra committed
33

Nicolas Van der Noot's avatar
Nicolas Van der Noot committed
34
35
36
37
38
39
    configure_file (
        "./sdl/conf/cmake_sdl_config.h.in"
        "${PROJECT_BINARY_DIR}/conf/cmake_sdl_config.h"
    )
    include_directories ("${PROJECT_BINARY_DIR}/conf")
endif ()
Timothee Habra's avatar
Timothee Habra committed
40

Nicolas Van der Noot's avatar
Nicolas Van der Noot committed
41
42
43
44
45
46
# 3D visualisation
if(FLAG_VISU)
    include_directories("./visu_past")
    increment_src( ${PROJECT_SOURCE_DIR}/visu_past )
endif ()

Timothee Habra's avatar
Timothee Habra committed
47
# Get java lib and add java functions to src
48
if (FLAG_JAVA)
Timothee Habra's avatar
Timothee Habra committed
49

Nicolas Van der Noot's avatar
Nicolas Van der Noot committed
50
51
52
    # find java and java 3d
    java_lib(mbs_realtime)
    set(JNI_LIBRARIES ${JNI_LIBRARIES} PARENT_SCOPE)
Nicolas Van der Noot's avatar
Nicolas Van der Noot committed
53
    set(J3D_PATH ${J3D_PATH} PARENT_SCOPE)
Timothee Habra's avatar
Timothee Habra committed
54

Nicolas Van der Noot's avatar
Nicolas Van der Noot committed
55
    include_directories("./java")
56
    increment_src( ${PROJECT_SOURCE_DIR}/java )
Timothee Habra's avatar
Timothee Habra committed
57

Nicolas Van der Noot's avatar
Nicolas Van der Noot committed
58
59
60
61
62
    if (APPLE)
        set(JAR_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../mbsyspad_mac_os/MBsysPad.jar)
    else ( )
        set(JAR_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../mbsyspad/MBsysPad.jar)
    endif ( )
Timothee Habra's avatar
Timothee Habra committed
63

Nicolas Van der Noot's avatar
Nicolas Van der Noot committed
64
65
66
67
68
69
    configure_file (
        "./java/conf/cmake_java_config.h.in"
        "${PROJECT_BINARY_DIR}/conf/cmake_java_config.h"
    )
    include_directories ("${PROJECT_BINARY_DIR}/conf")
endif ()
Timothee Habra's avatar
Timothee Habra committed
70

71
72
73
# Get OpenGL lib
if (FLAG_OPEN_GL)

74
75
76
77
78
79
    # Threads
    if (UNIX)
        p_threads_lib(mbs_realtime)
        set(CMAKE_THREAD_LIBS_INIT ${CMAKE_THREAD_LIBS_INIT} PARENT_SCOPE)
    endif()

Nicolas Van der Noot's avatar
Nicolas Van der Noot committed
80
81
82
83
84
85
86
87
88
89
90
91
    # find Libxml2
    xml_lib(mbs_realtime)
    include_directories(${LIBXML2_INCLUDE_DIR})

    # find OpenGL
    open_gl_lib(mbs_realtime)
    set(OPEN_GL_INCLUDE_PATH ${OPEN_GL_INCLUDE_PATH} PARENT_SCOPE)
    set(OPEN_GL_LIBS ${OPEN_GL_LIBS} PARENT_SCOPE)

    include_directories("./open_gl")
    include_directories("./open_gl/anim_read")
    include_directories("./open_gl/components")
Nicolas Van der Noot's avatar
Nicolas Van der Noot committed
92
    include_directories("./open_gl/interface")
Nicolas Van der Noot's avatar
Nicolas Van der Noot committed
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
    include_directories("./open_gl/lights")
    include_directories("./open_gl/lights/specific")
    include_directories("./open_gl/loader")
    include_directories("./open_gl/loader/manual/vrml")
    include_directories("./open_gl/loader/obj")
    include_directories("./open_gl/shaders")
    include_directories("./open_gl/shapes")
    include_directories("./open_gl/shapes/specific")
    include_directories("./open_gl/viewpoint")
    include_directories("./open_gl/viewpoint/specific")
    include_directories("./open_gl/world")

    increment_src( ${PROJECT_SOURCE_DIR}/open_gl )

    set(OPEN_GL_FILES_PATH ${CMAKE_CURRENT_SOURCE_DIR}/open_gl/)

    configure_file (
        "./open_gl/conf/cmake_open_gl_config.h.in"
        "${PROJECT_BINARY_DIR}/conf/cmake_open_gl_config.h"
    )
    include_directories ("${PROJECT_BINARY_DIR}/conf")
114
115
endif ()

Timothee Habra's avatar
Timothee Habra committed
116
117
# list include directories (to find headers)
init_include()
118
set(INCLUDE_DIR ${INCLUDE_DIR} ${PROJECT_SOURCE_DIR}/realtime PARENT_SCOPE)
Timothee Habra's avatar
Timothee Habra committed
119

Timothee Habra's avatar
Timothee Habra committed
120
121
set(LIB_MBSYSC_REALTIME MBsysC_realtime)
set(LIB_MBSYSC_REALTIME ${LIB_MBSYSC_REALTIME} PARENT_SCOPE)
122
123
124


if(FLAG_SHARED_LIB)
125
	add_library(${LIB_MBSYSC_REALTIME} SHARED ${SOURCE_FILES} ${INCLUDE_DIR})			
126
127
128
129
130
else()
	add_library(${LIB_MBSYSC_REALTIME} STATIC ${SOURCE_FILES} ${INCLUDE_DIR})
	add_definitions( -DPROJECT_USERFCT_STATIC_DEFINE)
	add_definitions( -DPROJECT_UTILITIES_STATIC_DEFINE)
endif()
Timothee Habra's avatar
Timothee Habra committed
131

132
133
134
135
136
if(FLAG_PRJ_FCT_PTR)
	add_definitions( -DPROJECT_USERFCT_STATIC_DEFINE)
	target_link_libraries (${LIB_MBSYSC_REALTIME} MBsysC_struct) 
endif()

Nicolas Van der Noot's avatar
Nicolas Van der Noot committed
137
138
139
140
141
# Windows M_PI definition
if (WIN32)
    add_definitions( -D_USE_MATH_DEFINES)
endif (WIN32)

142
target_link_libraries (${LIB_MBSYSC_REALTIME} ${LIB_MBSYSC_UTILITIES}) 
Timothee Habra's avatar
Timothee Habra committed
143
144

include (GenerateExportHeader)
145
GENERATE_EXPORT_HEADER( ${LIB_MBSYSC_REALTIME}	)
Timothee Habra's avatar
Timothee Habra committed
146
include_directories(${CMAKE_CURRENT_BINARY_DIR})
147
install (TARGETS ${LIB_MBSYSC_REALTIME} DESTINATION ${CMAKE_INSTALL_PREFIX})
Timothee Habra's avatar
Timothee Habra committed
148

Nicolas Van der Noot's avatar
Nicolas Van der Noot committed
149
150
# SDL external library: linkage
if (FLAG_PLOT)
151
    target_link_libraries (${LIB_MBSYSC_REALTIME} ${SDL2_LIBRARIES} ${SDL2TTF_LIBRARIES})
Nicolas Van der Noot's avatar
Nicolas Van der Noot committed
152
153
154
endif ( )

# Java external library: linkage
155
if (FLAG_JAVA)
156
    target_link_libraries (${LIB_MBSYSC_REALTIME} ${JNI_LIBRARIES})
Nicolas Van der Noot's avatar
Nicolas Van der Noot committed
157
158
endif ( )

159
160
# OpenGl external library: linkage
if (FLAG_OPEN_GL)
Nicolas Van der Noot's avatar
Nicolas Van der Noot committed
161
    target_link_libraries (${LIB_MBSYSC_REALTIME} ${OPEN_GL_LIBS})
162
163
164
165

    if (UNIX)
        target_link_libraries (${LIB_MBSYSC_REALTIME} ${CMAKE_THREAD_LIBS_INIT})
    endif ( )
166
167
endif ( )

168
169
set(LIB_MBSYSC_REALTIME_PATH ${CMAKE_CURRENT_BINARY_DIR} PARENT_SCOPE)

Nicolas Van der Noot's avatar
Nicolas Van der Noot committed
170
# include directories
Timothee Habra's avatar
Timothee Habra committed
171
172
include_directories("./")
include_directories("./sdl" "./sdl/auto_plot")
173
include_directories("./realtime")
Nicolas Van der Noot's avatar
Nicolas Van der Noot committed
174
175
include_directories("../mbs_struct")
include_directories("../mbs_utilities")