CMakeLists.txt 2.91 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
25
26
#
# 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
cmake_minimum_required(VERSION 2.8.7)

# project name
project (GEN_MDS_USER)

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

# use Release version and not the Debug one (faster)
set(CMAKE_BUILD_TYPE Debug)

# for Unix: display all the warnings, except the ones related to /* -- */
if (UNIX)
  set(CMAKE_C_FLAGS "-g -Wall -Wno-comment -Wno-unused-variable")
endif (UNIX)

27
28
29
set(ROBOTRAN_DIR_COMMON "${PROJECT_SOURCE_DIR}/../../")
set(ROBOTRAN_SOURCE_DIR ${ROBOTRAN_DIR_COMMON}) 

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

33
34
35
36
# 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/)
37

38
39
# Libxml2
xml_lib()
40
41
42

# function to list all source files in the src/ directory, 
# recursing into sub-directories
43
function(list_gen_source_files)
44
45
    file(GLOB_RECURSE SOURCE_FILES_TMP 
		"${PROJECT_SOURCE_DIR}/src/*.c" 
46
47
		"${ROBOTRAN_SOURCE_DIR}/mbs_common/mbs_load_xml/mbs_xml_reader.c"
		"${ROBOTRAN_SOURCE_DIR}/mbs_common/mbs_utilities/useful_functions.c")
48
49
50
51
52
    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)
53
function(list_gen_include_directories)
54
55
    file(GLOB_RECURSE FULL_INCLUDE_DIRECTORIES_TMP RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} 
		"${PROJECT_SOURCE_DIR}/src/*.h"
56
57
		"${ROBOTRAN_SOURCE_DIR}/mbs_common/mbs_load_xml/mbs_xml_reader.h"
		"${ROBOTRAN_SOURCE_DIR}/mbs_common/mbs_utilities/useful_functions.h"
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
		)
    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})

target_link_libraries (${Executable} ${LIBXML2_LIBRARIES})

if (WIN32)
86
	file(COPY ${ROBOTRAN_SOURCE_DIR}/win64_include_lib/dll/libxml2.dll DESTINATION ${CMAKE_BINARY_DIR}/Debug)
87
88
89
90
91
92
endif (WIN32)

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