CMakeLists.txt 6.14 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

Olivier Lantsoght's avatar
Olivier Lantsoght committed
5
cmake_minimum_required(VERSION 3.4)
Timothee Habra's avatar
Timothee Habra committed
6
7
8

project(MBsysC_realtime)

9
# Preprocessor definition, in order to suppress the warnings : (ST)
10
# "Avertissement    C4996    'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details."
11
12
13
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
add_definitions(-D_CRT_NONSTDC_NO_WARNINGS)

14
15
# define GLM_ENABLE_EXPERIMENTAL to use <glm/gtx/transform.hpp> and <gtx/color_space.hpp> 
add_definitions(-D GLM_ENABLE_EXPERIMENTAL)
16
17
18
19

# release of debug
release_debug()

Timothee Habra's avatar
Timothee Habra committed
20
21
# list source files to compile
init_src()
22
23
increment_src( ${PROJECT_SOURCE_DIR}/realtime )
increment_src( ${PROJECT_SOURCE_DIR}/void )
24
set(SOURCE_FILES ${SOURCE_FILES} "${PROJECT_SOURCE_DIR}/mbs_project_realtime_fct_ptr.c")
Timothee Habra's avatar
Timothee Habra committed
25
26
27
28

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

Nicolas Van der Noot's avatar
Nicolas Van der Noot committed
29
30
31
32
    # 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
33

34
    increment_src( ${PROJECT_SOURCE_DIR}/sdl )
Timothee Habra's avatar
Timothee Habra committed
35

Nicolas Van der Noot's avatar
Nicolas Van der Noot committed
36
37
    # 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
38

Nicolas Van der Noot's avatar
Nicolas Van der Noot committed
39
40
41
42
43
44
    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
45

Nicolas Van der Noot's avatar
Nicolas Van der Noot committed
46
47
48
49
50
51
# 3D visualisation
if(FLAG_VISU)
    include_directories("./visu_past")
    increment_src( ${PROJECT_SOURCE_DIR}/visu_past )
endif ()

Timothee Habra's avatar
Timothee Habra committed
52
# Get java lib and add java functions to src
53
if (FLAG_JAVA)
Timothee Habra's avatar
Timothee Habra committed
54

Nicolas Van der Noot's avatar
Nicolas Van der Noot committed
55
56
57
    # 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
58
    set(J3D_PATH ${J3D_PATH} PARENT_SCOPE)
Timothee Habra's avatar
Timothee Habra committed
59

Nicolas Van der Noot's avatar
Nicolas Van der Noot committed
60
    include_directories("./java")
61
    increment_src( ${PROJECT_SOURCE_DIR}/java )
Timothee Habra's avatar
Timothee Habra committed
62

Nicolas Van der Noot's avatar
Nicolas Van der Noot committed
63
64
65
66
67
    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
68

Nicolas Van der Noot's avatar
Nicolas Van der Noot committed
69
70
71
72
73
74
    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
75

76
# Get OpenGL lib
77
if (FLAG_REAL_TIME AND FLAG_OPEN_GL)
78
79
80
81
82
83
    # 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
84
85
86
87
88
89
90
91
92
93
94
95
    # 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
96
    include_directories("./open_gl/interface")
Nicolas Van der Noot's avatar
Nicolas Van der Noot committed
97
98
99
    include_directories("./open_gl/lights")
    include_directories("./open_gl/lights/specific")
    include_directories("./open_gl/loader")
100
    include_directories("./open_gl/loader/vrml")
Nicolas Van der Noot's avatar
Nicolas Van der Noot committed
101
    include_directories("./open_gl/loader/obj")
102
    include_directories("./open_gl/loader/stl")
103
    include_directories("./open_gl/mbs_read")
Nicolas Van der Noot's avatar
Nicolas Van der Noot committed
104
105
106
107
108
109
    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")
110
    include_directories("./open_gl/renderer")
111
    include_directories("./open_gl/renderer/default")
112
113
114
115
    include_directories("./open_gl/renderer/ogl")
    include_directories("./open_gl/specific_include")
    include_directories("./open_gl/window")
    include_directories("./open_gl/window/glfw")
Nicolas Van der Noot's avatar
Nicolas Van der Noot committed
116

117
118
119
120
121
122
123
124
    # Frame capture
    if(FLAG_FRAME_CAPTURE)
        include_directories("./open_gl/frame_capture")
        find_package(PNG)
        set(FFmpeg_FIND_COMPONENTS AVCODEC AVFORMAT AVUTIL SWSCALE)
        find_package(FFMPEG REQUIRED)
    endif()

Nicolas Van der Noot's avatar
Nicolas Van der Noot committed
125
126
127
128
129
130
131
132
133
    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")
134
135
endif ()

Timothee Habra's avatar
Timothee Habra committed
136
137
# list include directories (to find headers)
init_include()
138
set(INCLUDE_DIR ${INCLUDE_DIR} ${PROJECT_SOURCE_DIR}/realtime PARENT_SCOPE)
Timothee Habra's avatar
Timothee Habra committed
139

Timothee Habra's avatar
Timothee Habra committed
140
141
set(LIB_MBSYSC_REALTIME MBsysC_realtime)
set(LIB_MBSYSC_REALTIME ${LIB_MBSYSC_REALTIME} PARENT_SCOPE)
142
143
144


if(FLAG_SHARED_LIB)
145
    add_library(${LIB_MBSYSC_REALTIME} SHARED ${SOURCE_FILES} ${INCLUDE_DIR})
146
else()
147
    add_library(${LIB_MBSYSC_REALTIME} STATIC ${SOURCE_FILES} ${INCLUDE_DIR})
148
149
endif()

150
target_link_libraries (${LIB_MBSYSC_REALTIME} ${LIB_MBSYSC_UTILITIES}) 
Timothee Habra's avatar
Timothee Habra committed
151

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

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

162
163
# OpenGl external library: linkage
if (FLAG_OPEN_GL)
164
    target_link_libraries (${LIB_MBSYSC_REALTIME} ${OPEN_GL_LIBS} ${LIBXML2_LIBRARIES})
165
166
167
168

    if (UNIX)
        target_link_libraries (${LIB_MBSYSC_REALTIME} ${CMAKE_THREAD_LIBS_INIT})
    endif ( )
169
170
endif ( )

171
172
173
174
175
176
# Frame capture
if(FLAG_FRAME_CAPTURE)
    target_link_libraries (${LIB_MBSYSC_REALTIME} ${PNG_LIBRARIES})
    target_link_libraries (${LIB_MBSYSC_REALTIME} ${FFMPEG_LIBRARIES}) # ${SWSCALE_LIBRARIES})
endif()

177
178
set(LIB_MBSYSC_REALTIME_PATH ${CMAKE_CURRENT_BINARY_DIR} PARENT_SCOPE)

Nicolas Van der Noot's avatar
Nicolas Van der Noot committed
179
# include directories
Timothee Habra's avatar
Timothee Habra committed
180
181
include_directories("./")
include_directories("./sdl" "./sdl/auto_plot")
182
include_directories("./realtime")
Nicolas Van der Noot's avatar
Nicolas Van der Noot committed
183
184
include_directories("../mbs_struct")
include_directories("../mbs_utilities")
185
include_directories("../mbs_numerics")
186
187

# separate executable for Windows Open GL
Nicolas Van der Noot's avatar
Nicolas Van der Noot committed
188
if (FLAG_OPEN_GL)
189
    set (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
190
191
    add_subdirectory ( open_gl/process/  ${CMAKE_CURRENT_BINARY_DIR}/open_gl/process/ )
endif ()