Commit 5514cd0b authored by Ghislain MARY's avatar Ghislain MARY

Add CMake file to put CMake utils fnuctions and macros.

parent 8ed19292
......@@ -48,27 +48,12 @@ option(ENABLE_TESTS_COMPONENT "Enable compilation of tests helper library" ON)
option(ENABLE_TESTS "Enable compilation of tests" ON)
macro(apply_compile_flags SOURCE_FILES)
if(${SOURCE_FILES})
set(options "")
foreach(a ${ARGV})
if(STRICT_OPTIONS_${a})
string(REPLACE ";" " " options_${a} "${STRICT_OPTIONS_${a}}")
set(options "${options} ${options_${a}}")
endif()
endforeach()
if(options)
set_source_files_properties(${${SOURCE_FILES}} PROPERTIES COMPILE_FLAGS "${options}")
endif()
endif()
endmacro()
include(CheckLibraryExists)
include(CheckSymbolExists)
include(CheckCSourceCompiles)
include(CMakePushCheckState)
include(GNUInstallDirs)
include(cmake/BcToolboxCMakeUtils.cmake)
add_subdirectory(build)
......@@ -226,6 +211,7 @@ configure_file(cmake/BcToolboxConfig.cmake.in
"${CMAKE_CURRENT_BINARY_DIR}/BcToolboxConfig.cmake"
@ONLY
)
configure_file(cmake/BcToolboxCMakeUtils.cmake "${CMAKE_CURRENT_BINARY_DIR}/BcToolboxCMakeUtils.cmake" COPYONLY)
set(CONFIG_PACKAGE_LOCATION "${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}/cmake")
install(EXPORT ${EXPORT_TARGETS_NAME}Targets
......@@ -235,5 +221,6 @@ install(EXPORT ${EXPORT_TARGETS_NAME}Targets
install(FILES
"${CMAKE_CURRENT_BINARY_DIR}/BcToolboxConfig.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/BcToolboxConfigVersion.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/BcToolboxCMakeUtils.cmake"
DESTINATION ${CONFIG_PACKAGE_LOCATION}
)
############################################################################
# BcToolboxCMakeUtils.cmake
# Copyright (C) 2017 Belledonne Communications, Grenoble France
#
############################################################################
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
############################################################################
macro(bc_apply_compile_flags SOURCE_FILES)
if(${SOURCE_FILES})
set(options "")
foreach(a ${ARGN})
if(${a})
string(REPLACE ";" " " options_${a} "${${a}}")
set(options "${options} ${options_${a}}")
endif()
endforeach()
if(options)
set_source_files_properties(${${SOURCE_FILES}} PROPERTIES COMPILE_FLAGS "${options}")
endif()
endif()
endmacro()
......@@ -74,3 +74,5 @@ foreach(comp ${BcToolbox_FIND_COMPONENTS})
message(FATAL_ERROR "Required bctoolbox component \"${comp}\" cannot be found")
endif()
endforeach()
include("${CMAKE_CURRENT_LIST_DIR}/BcToolboxCMakeUtils.cmake")
......@@ -50,9 +50,9 @@ endif()
set(BCTOOLBOX_SOURCE_FILES ${BCTOOLBOX_C_SOURCE_FILES} ${BCTOOLBOX_CXX_SOURCE_FILES})
set(BCTOOLBOX_TESTER_SOURCE_FILES ${BCTOOLBOX_C_TESTER_SOURCE_FILES})
apply_compile_flags(BCTOOLBOX_C_SOURCE_FILES "CPP" "C")
apply_compile_flags(BCTOOLBOX_C_TESTER_SOURCE_FILES "CPP" "C")
apply_compile_flags(BCTOOLBOX_CXX_SOURCE_FILES "CPP" "CXX")
bc_apply_compile_flags(BCTOOLBOX_C_SOURCE_FILES STRICT_OPTIONS_CPP STRICT_OPTIONS_C)
bc_apply_compile_flags(BCTOOLBOX_C_TESTER_SOURCE_FILES STRICT_OPTIONS_CPP STRICT_OPTIONS_C)
bc_apply_compile_flags(BCTOOLBOX_CXX_SOURCE_FILES STRICT_OPTIONS_CPP STRICT_OPTIONS_CXX)
if(ENABLE_STATIC)
add_library(bctoolbox-static STATIC ${BCTOOLBOX_SOURCE_FILES} ${BCTOOLBOX_HEADER_FILES})
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment