CMakeLists.txt 3.87 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
#
# author: 
# Feb 27 2014
#
# CMakeLists used to generate the executable in charge of automatically
# generating the new versions of 'ControllersStruct.h/.c' and 'user_sf_IO.h/.c'
# when 'control_variables.txt' or 'simu_variables.txt' are modified
#

# CMake minimum version
Olivier Lantsoght's avatar
Olivier Lantsoght committed
11
cmake_minimum_required(VERSION 3.4)
12
13
14
15

# project name
project (GEN_MDS_USER)

16
# Preprocessor definition, in order to suppress the warnings : (ST)
17
# "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."
18
19
20
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
add_definitions(-D_CRT_NONSTDC_NO_WARNINGS)

21
22
23
# message to display the project name
message(STATUS "Processing ${PROJECT_NAME}")

24
25
26
set(ROBOTRAN_DIR_COMMON "${PROJECT_SOURCE_DIR}/../../")
set(ROBOTRAN_SOURCE_DIR ${ROBOTRAN_DIR_COMMON}) 

27
# define the location of all the 'Find<module>.cmake' files
28
set(CMAKE_MODULE_PATH ${ROBOTRAN_SOURCE_DIR}/conf)
29

30
31
32
33
# add additional CMakeLists.txt files
set(CMAKE_AUX ${ROBOTRAN_SOURCE_DIR}/cmake_aux)
set(CMAKE_AUX_BIN ${PROJECT_BINARY_DIR}/cmake_aux)
add_subdirectory (${CMAKE_AUX}/libraries/ ${CMAKE_AUX_BIN}/libraries/)
34

35
36
37
mbsysc_specific_flags() #TODO move to mbsysC cmake
flags_check()
release_debug()
38
39
40
41

if (WIN32)

## --- WIN32 or WIN64 DETECTION --- ##
42
43
44
45
46
    if( CMAKE_SIZEOF_VOID_P EQUAL 8 )   # 64bit Windows
        SET(WIN_LIB_DIRECTORY win64_include_lib)
    else( )  # 32bit Windows
        SET(WIN_LIB_DIRECTORY win32_include_lib)
    endif( )
47
48
49
50
51

## ---- WINDOWS DLL FILES ---- ##

# copy all the dll (except 'jvm.dll') used for Windows
# these dll files are copied in the Executable directory (Debug or Release)
52
53
54

    file(COPY ${ROBOTRAN_SOURCE_DIR}/${WIN_LIB_DIRECTORY}/dll/ DESTINATION ${EXECUTABLE_OUTPUT_PATH}/Debug)
    file(COPY ${ROBOTRAN_SOURCE_DIR}/${WIN_LIB_DIRECTORY}/dll/ DESTINATION ${EXECUTABLE_OUTPUT_PATH}/Release)
55
    
56
57
58
endif ( )


59
# Libxml2
60
xml_lib(gen_user)
61
62
63

# function to list all source files in the src/ directory, 
# recursing into sub-directories
64
function(list_gen_source_files)
65
    file(GLOB_RECURSE SOURCE_FILES_TMP 
66
67
68
                "${PROJECT_SOURCE_DIR}/src/*.c" 
                "${ROBOTRAN_SOURCE_DIR}/mbs_common/mbs_load_xml/mbs_xml_binder.c"
                "${ROBOTRAN_SOURCE_DIR}/mbs_common/mbs_utilities/useful_functions.c")
69
70
71
72
73
    set(SOURCE_FILES ${SOURCE_FILES_TMP} PARENT_SCOPE)
endfunction()

# function to list all paths to header files in the src/ directory, 
# recursing into sub-directories (includes)
74
function(list_gen_include_directories)
75
    file(GLOB_RECURSE FULL_INCLUDE_DIRECTORIES_TMP RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} 
76
        "${PROJECT_SOURCE_DIR}/src/*.h"
77
78
79
                "${ROBOTRAN_SOURCE_DIR}/mbs_common/mbs_load_xml/mbs_xml_binder_public.h"
                "${ROBOTRAN_SOURCE_DIR}/mbs_common/mbs_load_xml/mbs_xml_binder_private.h"
                "${ROBOTRAN_SOURCE_DIR}/mbs_common/mbs_utilities/useful_functions.h"
80
                "${ROBOTRAN_SOURCE_DIR}/mbs_common/mbs_struct/mbs_data.h"
81
        )
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
    set(DIR_LIST "")
    foreach(FILE_PATH ${FULL_INCLUDE_DIRECTORIES_TMP})
        get_filename_component(DIR_PATH ${FILE_PATH} PATH)
        set(DIR_LIST ${DIR_LIST} ${DIR_PATH})
    endforeach(FILE_PATH)
    list(REMOVE_DUPLICATES DIR_LIST) 
    set(FULL_INCLUDE_DIRECTORIES ${DIR_LIST} PARENT_SCOPE)
endfunction()
 
# list source files to compile
list_gen_source_files(SOURCE_FILES)

# list include directories (to find headers)
list_gen_include_directories(FULL_INCLUDE_DIRECTORIES)

# include these directories
include_directories (${FULL_INCLUDE_DIRECTORIES})

# name of the executable: 'Gen_mds_user'
set (Executable Gen_mds_user)

# generate the executable
add_executable (${Executable} ${SOURCE_FILES})

106
target_link_libraries (${Executable} ${LIBXML2_LIBRARIES} ${LIB_MBSYSC_UTILITIES})
107
108
109
110


# math external library (for Unix): linkage
if (UNIX)
111
    target_link_libraries (${Executable} m)
112
endif ( )