[97] | 1 | if(DEFINED GLOBALCMAKEFLAIR_INCLUDED)
|
---|
| 2 | return()
|
---|
[2] | 3 | endif()
|
---|
| 4 |
|
---|
[97] | 5 | SET(GLOBALCMAKEFLAIR_INCLUDED true)
|
---|
| 6 |
|
---|
[2] | 7 | include($ENV{FLAIR_ROOT}/flair-dev/cmake-modules/ColoredMessage.cmake)
|
---|
| 8 |
|
---|
[97] | 9 | #check if we have a flair-hds directory
|
---|
| 10 | if (IS_DIRECTORY $ENV{FLAIR_ROOT}/flair-hds )
|
---|
| 11 | info("found flair-hds directory")
|
---|
| 12 | SET(FOUND_HDS_DIR TRUE)
|
---|
| 13 | endif()
|
---|
| 14 |
|
---|
[2] | 15 | if(NOT DEFINED ENV{FLAIR_ROOT})
|
---|
[97] | 16 | message(FATAL_ERROR "variable FLAIR_ROOT not defined")
|
---|
| 17 | endif()
|
---|
| 18 |
|
---|
| 19 | if(NOT DEFINED ENV{FLAIR_ROOT})
|
---|
[2] | 20 | err("variable FLAIR_ROOT not defined")
|
---|
| 21 | endif()
|
---|
| 22 |
|
---|
| 23 | if(NOT FLAIR_DEV)
|
---|
| 24 | IF(FLAIR_DEV_TAG)
|
---|
[10] | 25 | warn("Configuring flair-dev and flair-bin for tag ${FLAIR_DEV_TAG}")
|
---|
[2] | 26 | SET(FLAIR_DEV $ENV{FLAIR_ROOT}/flair-dev_svn/tags/${FLAIR_DEV_TAG})
|
---|
[10] | 27 | SET(FLAIR_BIN $ENV{FLAIR_ROOT}/flair-bin_svn/tags/${FLAIR_DEV_TAG})
|
---|
[2] | 28 | if(EXISTS "${FLAIR_DEV}/cmake-modules/GlobalCmakeUAV.cmake")
|
---|
| 29 | UNSET(FLAIR_DEV_TAG)
|
---|
| 30 | include(${FLAIR_DEV}/cmake-modules/GlobalCmakeUAV.cmake)
|
---|
| 31 | return()
|
---|
| 32 | else()
|
---|
| 33 | err("File not found ${FLAIR_DEV}/cmake-modules/GlobalCmakeUAV.cmake Please check that ${FLAIR_DEV} is up to date")
|
---|
| 34 | endif()
|
---|
| 35 | ELSE()
|
---|
| 36 | SET(FLAIR_DEV $ENV{FLAIR_ROOT}/flair-dev)
|
---|
[10] | 37 | SET(FLAIR_BIN $ENV{FLAIR_ROOT}/flair-bin)
|
---|
[2] | 38 | ENDIF()
|
---|
| 39 | ENDIF()
|
---|
| 40 |
|
---|
| 41 | include(${FLAIR_DEV}/cmake-modules/ArchDir.cmake)
|
---|
| 42 |
|
---|
| 43 | list(APPEND CMAKE_MODULE_PATH ${FLAIR_DEV}/cmake-modules/)
|
---|
| 44 |
|
---|
| 45 | #framework
|
---|
| 46 | SET(FLAIR_USE_FILE ${FLAIR_DEV}/cmake-modules/FlairUseFile.cmake)
|
---|
| 47 |
|
---|
| 48 | #default executable ouput paths
|
---|
| 49 | if(NOT DEFINED EXECUTABLE_OUTPUT_PATH)
|
---|
| 50 | SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
|
---|
| 51 | endif()
|
---|
| 52 | if(NOT DEFINED TARGET_EXECUTABLE_OUTPUT_PATH)
|
---|
| 53 | SET(TARGET_EXECUTABLE_OUTPUT_PATH bin/arm)
|
---|
| 54 | endif()
|
---|
| 55 |
|
---|
[81] | 56 | #add definitions for archs
|
---|
| 57 | if("${CMAKE_SYSTEM_PROCESSOR_DEFAULTTUNE}" MATCHES "armv7a-neon")
|
---|
| 58 | ADD_DEFINITIONS(-DARMV7A)
|
---|
| 59 | endif()
|
---|
| 60 |
|
---|
| 61 | if("${CMAKE_SYSTEM_PROCESSOR_DEFAULTTUNE}" MATCHES "armv5te")
|
---|
| 62 | ADD_DEFINITIONS(-DARMV5TE)
|
---|
| 63 | endif()
|
---|
| 64 |
|
---|
| 65 | if("${CMAKE_SYSTEM_PROCESSOR_DEFAULTTUNE}" MATCHES "core2-64")
|
---|
| 66 | ADD_DEFINITIONS(-DCORE2_64)
|
---|
| 67 | endif()
|
---|
| 68 |
|
---|
[2] | 69 | #reimplement add executable to add a custom target for delivery (only on ARM)
|
---|
| 70 | #delivery are read from ssh config file
|
---|
[97] | 71 | #also add a message to display architecture
|
---|
[2] | 72 | function(ADD_EXECUTABLE)
|
---|
| 73 | if("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "arm" AND EXISTS "$ENV{HOME}/.ssh/config")
|
---|
| 74 | file(STRINGS $ENV{HOME}/.ssh/config TEST)
|
---|
| 75 | foreach(f ${TEST})
|
---|
| 76 | string(FIND ${f} "Host " POS)#cherche ligne host
|
---|
| 77 | if(${POS} GREATER -1)
|
---|
| 78 | string(REPLACE Host "" TARGET_NAME ${f})#enleve Host
|
---|
| 79 | string(STRIP ${TARGET_NAME} TARGET_NAME)#enleve les espaces
|
---|
| 80 | endif()
|
---|
| 81 | string(FIND ${f} HostName POS)#cherche hostname
|
---|
| 82 | if(${POS} GREATER -1)
|
---|
| 83 | string(FIND ${f} "192.168." POS)#cherche addresse
|
---|
[97] | 84 | if(${POS} GREATER 0)#garde que les adresses en 192.168.x.x
|
---|
[2] | 85 | string(REPLACE HostName "" ADDRESS ${f})#enleve Hostname
|
---|
| 86 | string(STRIP ${ADDRESS} ADDRESS)#enleve les espaces
|
---|
[97] | 87 | #message("adding delivery target for " ${ARGV0} " (" ${ADDRESS} ")")
|
---|
[2] | 88 | string(REPLACE "/" "_" TARGET_PATH ${TARGET_EXECUTABLE_OUTPUT_PATH})#les / ne sont pas acceptés
|
---|
| 89 | add_custom_target(
|
---|
[44] | 90 | delivery_root_${ADDRESS}_${TARGET_PATH}_${ARGV0}
|
---|
[2] | 91 | COMMAND make
|
---|
| 92 | COMMAND scp ${EXECUTABLE_OUTPUT_PATH}/${ARGV0} root@${ADDRESS}:${TARGET_EXECUTABLE_OUTPUT_PATH}
|
---|
| 93 | )
|
---|
| 94 | endif()
|
---|
| 95 | endif()
|
---|
| 96 | endforeach(f)
|
---|
| 97 | endif()
|
---|
[97] | 98 |
|
---|
| 99 | #call original function
|
---|
[2] | 100 | _ADD_EXECUTABLE(${ARGV})
|
---|
[97] | 101 |
|
---|
| 102 | #add a message to display architecture
|
---|
| 103 | string(SUBSTRING ${ARGV0} 0 5 TESTNAME) #check if it is qt4 internal target
|
---|
| 104 | if(NOT ${TESTNAME} MATCHES "Qt4::")
|
---|
| 105 | add_custom_command(TARGET ${ARGV0} POST_BUILD
|
---|
| 106 | COMMENT "${ARGV0} built for ${CMAKE_SYSTEM_PROCESSOR_DEFAULTTUNE} architecture")
|
---|
| 107 | endif()
|
---|
| 108 |
|
---|
| 109 | #add a dependance to FlairLibs and FlairHdsLibs if we use the top level CMakeLists.txt and we need flairlibs
|
---|
| 110 | if(TARGET FlairLibs AND DEFINED FLAIRUSEFILE_INCLUDED)
|
---|
| 111 | add_dependencies(${ARGV0} FlairLibs)
|
---|
| 112 | endif()
|
---|
| 113 | if(TARGET FlairHdsLibs AND DEFINED FLAIRUSEFILE_INCLUDED)
|
---|
| 114 | add_dependencies(${ARGV0} FlairHdsLibs)
|
---|
| 115 | endif()
|
---|
[2] | 116 | endfunction()
|
---|
[97] | 117 |
|
---|
| 118 |
|
---|
| 119 | #reimplement add library to add a message to display architecture
|
---|
| 120 | function(ADD_LIBRARY)
|
---|
| 121 | #call original function
|
---|
| 122 | _ADD_LIBRARY(${ARGV})
|
---|
| 123 | string(SUBSTRING ${ARGV0} 0 5 TESTNAME) #check if it is qt4 internal target
|
---|
| 124 | if(NOT ${TESTNAME} MATCHES "Qt4::")
|
---|
| 125 | add_custom_command(TARGET ${ARGV0} POST_BUILD
|
---|
| 126 | COMMENT "${ARGV0} built for ${CMAKE_SYSTEM_PROCESSOR_DEFAULTTUNE} architecture")
|
---|
| 127 | endif()
|
---|
| 128 | endfunction()
|
---|