source: flair-dev/trunk/cmake-modules/GlobalCmakeFlair.cmake@ 3

Last change on this file since 3 was 2, checked in by Sanahuja Guillaume, 8 years ago

initial commit flaircore

File size: 2.5 KB
Line 
1if(NOT DEFINED ENV{FLAIR_ROOT})
2 message(FATAL_ERROR "variable FLAIR_ROOT not defined")
3endif()
4
5include($ENV{FLAIR_ROOT}/flair-dev/cmake-modules/ColoredMessage.cmake)
6
7if(NOT DEFINED ENV{FLAIR_ROOT})
8 err("variable FLAIR_ROOT not defined")
9endif()
10
11if(NOT FLAIR_DEV)
12 IF(FLAIR_DEV_TAG)
13 warn("Configuring flair-dev for tag ${FLAIR_DEV_TAG}")
14 SET(FLAIR_DEV $ENV{FLAIR_ROOT}/flair-dev_svn/tags/${FLAIR_DEV_TAG})
15 if(EXISTS "${FLAIR_DEV}/cmake-modules/GlobalCmakeUAV.cmake")
16 UNSET(FLAIR_DEV_TAG)
17 include(${FLAIR_DEV}/cmake-modules/GlobalCmakeUAV.cmake)
18 return()
19 else()
20 err("File not found ${FLAIR_DEV}/cmake-modules/GlobalCmakeUAV.cmake Please check that ${FLAIR_DEV} is up to date")
21 endif()
22 ELSE()
23 SET(FLAIR_DEV $ENV{FLAIR_ROOT}/flair-dev)
24 ENDIF()
25ENDIF()
26
27include(${FLAIR_DEV}/cmake-modules/ArchDir.cmake)
28
29list(APPEND CMAKE_MODULE_PATH ${FLAIR_DEV}/cmake-modules/)
30
31#framework
32SET(FLAIR_USE_FILE ${FLAIR_DEV}/cmake-modules/FlairUseFile.cmake)
33
34#default executable ouput paths
35if(NOT DEFINED EXECUTABLE_OUTPUT_PATH)
36 SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
37endif()
38if(NOT DEFINED TARGET_EXECUTABLE_OUTPUT_PATH)
39 SET(TARGET_EXECUTABLE_OUTPUT_PATH bin/arm)
40endif()
41
42#reimplement add executable to add a custom target for delivery (only on ARM)
43#delivery are read from ssh config file
44function(ADD_EXECUTABLE)
45 if("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "arm" AND EXISTS "$ENV{HOME}/.ssh/config")
46 file(STRINGS $ENV{HOME}/.ssh/config TEST)
47 foreach(f ${TEST})
48 string(FIND ${f} "Host " POS)#cherche ligne host
49 if(${POS} GREATER -1)
50 string(REPLACE Host "" TARGET_NAME ${f})#enleve Host
51 string(STRIP ${TARGET_NAME} TARGET_NAME)#enleve les espaces
52 endif()
53 string(FIND ${f} HostName POS)#cherche hostname
54 if(${POS} GREATER -1)
55 string(FIND ${f} "192.168." POS)#cherche addresse
56 if(${POS} GREATER 0)#garde que les adresses en 192.168.6.x
57 string(REPLACE HostName "" ADDRESS ${f})#enleve Hostname
58 string(STRIP ${ADDRESS} ADDRESS)#enleve les espaces
59 message("adding delivery target for " ${ARGV0} " (" ${ADDRESS} ")")
60 string(REPLACE "/" "_" TARGET_PATH ${TARGET_EXECUTABLE_OUTPUT_PATH})#les / ne sont pas acceptés
61 add_custom_target(
62 delivery_root@${ADDRESS}_${TARGET_PATH}_${ARGV0}
63 COMMAND make
64 COMMAND scp ${EXECUTABLE_OUTPUT_PATH}/${ARGV0} root@${ADDRESS}:${TARGET_EXECUTABLE_OUTPUT_PATH}
65 )
66 endif()
67 endif()
68 endforeach(f)
69 endif()
70 #call original function
71 _ADD_EXECUTABLE(${ARGV})
72endfunction()
Note: See TracBrowser for help on using the repository browser.