CMakeLists_userfctR.txt 4.07 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#
#   Universite catholique de Louvain
#   CEREM : Centre for research in mechatronics
#   http://www.robotran.be  
#   Contact : info@robotran.be
#
#
# CMake for compiling the user files of a robotran project in C
# 

# * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
#                       LIBRARY MAIN CONFIGURATIONS
# * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

cmake_minimum_required(VERSION 2.8.7)

project(Project_userfct)

# flags
if (UNIX)
    set(CMAKE_C_FLAGS "-fPIC")
    set(CMAKE_EXE_LINKER_FLAGS "-fPIC")
endif (UNIX)

25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
#                        SEPARATE COMPILATION
# * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

if ( FLAG_SEPARATE_USER_FCT )

    # additional CMakeLists.txt
    set(CMAKE_AUX ${ROBOTRAN_SOURCE_DIR}/cmake_aux)
    set(CMAKE_AUX_BIN ${PROJECT_BINARY_DIR}/cmake_aux)

    add_subdirectory ( ${CMAKE_AUX}/flags/   ${CMAKE_AUX_BIN}/flags/   )
    add_subdirectory ( ${CMAKE_AUX}/listing/ ${CMAKE_AUX_BIN}/listing/ )
    add_subdirectory ( ${CMAKE_AUX}/libraries/ ${CMAKE_AUX_BIN}/libraries/ )

    # real-time option
    option (FLAG_REAL_TIME "Real time" OFF)

    if(FLAG_REAL_TIME)
        add_definitions( -DREAL_TIME )

        # configure a header file to pass some of the CMake settings to the source code
        configure_file (
            "${ROBOTRAN_SOURCE_DIR}/conf/cmake_config.h.in"
            "${PROJECT_BINARY_DIR}/conf/cmake_config.h"
        )
        include_directories (${PROJECT_BINARY_DIR}/conf)

        # plot-visu options
        option (FLAG_PLOT "Real time" OFF)
        option (FLAG_VISU "Real time" OFF)

        if(FLAG_PLOT)
            add_definitions( -DSDL )
        endif( )

        if(FLAG_VISU)
            add_definitions( -DJAVA )
        endif( )

    endif ( )
endif ( )

67
68
69
70
71
72
73
74
75
76
77
# release of debug
release_debug()

# * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
#                         SET LIBRARY
# * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

# list source files to compile
init_src()
increment_src( ${PROJECT_SOURCE_DIR} )

78
79
80
81
82
83
84
85
86
87
# list include directories (to find headers)
init_include()
increment_include( ${ROBOTRAN_SOURCE_DIR}/mbs_common )

# include these directories
include_directories ( ${INCLUDE_DIR} )
include_directories ( ${CMAKE_CURRENT_BINARY_DIR} )

if( FLAG_SHARED_LIB OR FLAG_SEPARATE_USER_FCT )
    add_library(Project_userfct SHARED ${SOURCE_FILES})
88
89

    target_link_libraries (Project_userfct ${LIB_MBSYSC_REALTIME})
90
    target_link_libraries (Project_userfct ${LIB_MBSYSC_MODULES})
91
    target_link_libraries (Project_userfct ${LIB_MBSYSC_UTILITIES})
92
93
94
95
96
97
    
    # MacOS: Force extension to be .so rather than .dylib
    if(APPLE)
        set_target_properties(Project_userfct PROPERTIES SUFFIX ".so")    
    endif()
    
98
else()
99
100
    add_library(Project_userfct STATIC ${SOURCE_FILES})
    add_definitions( -DMBSYSC_UTILITIES_STATIC_DEFINE)
101
    add_definitions( -DPROJECT_SYMBOLIC_STATIC_DEFINE)
102
103

    target_link_libraries (Project_userfct ${LIB_MBSYSC_REALTIME} ${LIB_MBSYSC_UTILITIES})
104
105
106
107
108
109
110
111
endif()

# * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
#                         LINK LIBRARIES
# * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

# MBSysC libraries
if ( FLAG_SEPARATE_BUILD ) # find MBSysC dynamic libraries
112
113
    find_package( LibRobotranC REQUIRED )
    add_definitions(${LIB_MBSYSC_DEFINITIONS})
114
115
116
117
118
119
120
121
122
123
124
endif()

if (FLAG_PLOT)
    sdl_header_lib(userfct)
endif ( )

# * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
#                         STUFF FOR WINDOWS (TO BE CLEANED)
# * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

include (GenerateExportHeader)
125
GENERATE_EXPORT_HEADER( Project_userfct )
126

127
install (TARGETS Project_userfct DESTINATION ${CMAKE_INSTALL_PREFIX})