########################################################################### # Copyright 2015, 2016, 2017 IoT.bzh # # author: Fulup Ar Foll # contrib: Romain Forlot # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. ########################################################################### #-------------------------------------------------------------------------- # WARNING: # Do not change this cmake template # Customise your preferences in "./etc/config.cmake" #-------------------------------------------------------------------------- # Get colorized message output non Windows OS. You know bash ? :) if(NOT WIN32) string(ASCII 27 Esc) set(ColourReset "${Esc}[m") set(ColourBold "${Esc}[1m") set(Red "${Esc}[31m") set(Green "${Esc}[32m") set(Yellow "${Esc}[33m") set(Blue "${Esc}[34m") set(Magenta "${Esc}[35m") set(Cyan "${Esc}[36m") set(White "${Esc}[37m") set(BoldRed "${Esc}[1;31m") set(BoldGreen "${Esc}[1;32m") set(BoldYellow "${Esc}[1;33m") set(BoldBlue "${Esc}[1;34m") set(BoldMagenta "${Esc}[1;35m") set(BoldCyan "${Esc}[1;36m") set(BoldWhite "${Esc}[1;37m") endif() # Generic useful macro # ----------------------- macro(PROJECT_TARGET_ADD TARGET_NAME) set_property(GLOBAL APPEND PROPERTY PROJECT_TARGETS ${TARGET_NAME}) set(TARGET_NAME ${TARGET_NAME}) endmacro(PROJECT_TARGET_ADD) # Check GCC minimal version version if (gcc_minimal_version) message (STATUS "${Blue}-- Check gcc_minimal_version (found gcc version ${CMAKE_C_COMPILER_VERSION}) (found g++ version ${CMAKE_CXX_COMPILER_VERSION})${ColourReset}") if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS ${gcc_minimal_version} OR CMAKE_C_COMPILER_VERSION VERSION_LESS ${gcc_minimal_version}) message(FATAL_ERROR "${Red}**** FATAL: Require at least gcc-${gcc_minimal_version} please set CMAKE_C[XX]_COMPILER") endif() endif(gcc_minimal_version) macro(defstr name value) add_definitions(-D${name}=${value}) endmacro(defstr) # WGT packaging macro(project_targets_populate) # Default Widget default directory set(PACKAGE_BINDIR ${PROJECT_PKG_DIR}/bin) set(PACKAGE_ETCDIR ${PROJECT_PKG_DIR}/etc) set(PACKAGE_LIBDIR ${PROJECT_PKG_DIR}/lib) set(PACKAGE_HTTPDIR ${PROJECT_PKG_DIR}/htdocs) set(PACKAGE_DATADIR ${PROJECT_PKG_DIR}/data) add_custom_target(populate) get_property(PROJECT_TARGETS GLOBAL PROPERTY PROJECT_TARGETS) foreach(TARGET ${PROJECT_TARGETS}) get_target_property(T ${TARGET} LABELS) if(T) # Declaration of a custom command that will populate widget tree with the target set(POPULE_PACKAGE_TARGET "project_populate_${TARGET}") get_target_property(P ${TARGET} PREFIX) get_target_property(BD ${TARGET} BINARY_DIR) get_target_property(OUT ${TARGET} OUTPUT_NAME) if(P MATCHES "NOTFOUND$") if (${T} STREQUAL "BINDING") set(P "lib") else() set(P "") endif() endif() if(${T} STREQUAL "BINDING") add_custom_command(OUTPUT ${PACKAGE_LIBDIR}/${P}${TARGET}.so DEPENDS ${TARGET} COMMAND mkdir -p ${PACKAGE_LIBDIR} COMMAND cp ${BD}/${P}${OUT}.so ${PACKAGE_LIBDIR} ) add_custom_target(${POPULE_PACKAGE_TARGET} DEPENDS ${PACKAGE_LIBDIR}/${P}${TARGET}.so) add_dependencies(populate ${POPULE_PACKAGE_TARGET}) elseif(${T} STREQUAL "EXECUTABLE") add_custom_command(OUTPUT ${PACKAGE_BINDIR}/${P}${TARGET} DEPENDS ${TARGET} COMMAND mkdir -p ${PACKAGE_BINDIR} COMMAND cp ${BD}/${P}${OUT} ${PACKAGE_BINDIR} ) add_custom_target(${POPULE_PACKAGE_TARGET} DEPENDS ${PACKAGE_BINDIR}/${P}${TARGET}) add_dependencies(populate ${POPULE_PACKAGE_TARGET}) elseif(${T} STREQUAL "HTDOCS") add_custom_command(OUTPUT ${PACKAGE_HTTPDIR} DEPENDS ${TARGET} COMMAND mkdir -p ${PROJECT_PKG_DIR}/${PACKAGE_HTTPDIR} COMMAND cp -r ${BD}/${P}${OUT}/* ${PACKAGE_HTTPDIR} ) add_custom_target(${POPULE_PACKAGE_TARGET} DEPENDS ${PACKAGE_HTTPDIR}) add_dependencies(populate ${POPULE_PACKAGE_TARGET}) elseif(${T} STREQUAL "DATA") add_custom_command(OUTPUT ${PACKAGE_DATADIR} DEPENDS ${TARGET} COMMAND mkdir -p ${PROJECT_PKG_DIR}/${PACKAGE_DATADIR} COMMAND cp -r ${BD}/${P}${OUT}/* ${PACKAGE_DATADIR} ) add_custom_target(${POPULE_PACKAGE_TARGET} DEPENDS ${PACKAGE_DATADIR}) add_dependencies(populate ${POPULE_PACKAGE_TARGET}) endif(${T} STREQUAL "BINDING") # elseif(${CMAKE_BUILD_TYPE} MATCHES "[Dd][Ee][Bb][Uu][Gg]") #