Skip to content

Commit

Permalink
State
Browse files Browse the repository at this point in the history
  • Loading branch information
swallat committed Dec 13, 2019
1 parent 35521dc commit 4cd1555
Show file tree
Hide file tree
Showing 8 changed files with 99 additions and 86 deletions.
10 changes: 10 additions & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# For more information, see:
#
# - https://github.com/blog/2392-introducing-code-owners

/packaging/ @swallat
/deps/ @swallat
/cmake/ @swallat
*.cmake @swallat
*/CMakeLists.txt @swallat
CMakeLists.txt @swallat
20 changes: 9 additions & 11 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,6 @@ if(CCACHE_FOUND)
message(STATUS "ccache found!")
endif(CCACHE_FOUND)

# Create LINUX variable if needed ToDo
if(UNIX AND NOT APPLE)
set(LINUX TRUE)
endif()

#Add path to CMake script files and include Helper
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/" "${CMAKE_SOURCE_DIR}/deps/sanitizers-cmake/cmake/")

Expand All @@ -60,10 +55,14 @@ option(PACKAGE_RPM "Package RPM package" OFF)
option(PACKAGE_MACOS "Package for macOS" OFF)

# Include Helper Modules
include(HalUtils) # Version helper
include(DetectDistro) # Detect distribution helper
include(Subdirs) # Get a lost of all subdirs in specific directory
include(find_packages)
include(hal_cmake_tools) # Version helper
include(find_openmp)

# Create LINUX variable if needed ToDo
if(UNIX AND NOT APPLE)
set(LINUX TRUE)
detect_distro()
endif()

# Check for valid Changelog file ToDo
set(DEB_CHANGELOG_REQUIRED ON)
Expand Down Expand Up @@ -137,7 +136,7 @@ endif(PkgConfig_FOUND)

find_package(Sanitizers)

# See cmake/find_packages.cmake
# See cmake/find_openmp.cmake
find_openmp()

find_package(Filesystem REQUIRED Final Experimental)
Expand Down Expand Up @@ -236,7 +235,6 @@ endif()
if(UNIX)
message(STATUS "Checking supported compiler flags...")

include(CompilerFlagsCheck)
enable_c_compiler_flag_if_supported("-Wall" "")
enable_c_compiler_flag_if_supported("-Wextra" "")
enable_c_compiler_flag_if_supported("-pedantic" "")
Expand Down
25 changes: 0 additions & 25 deletions cmake/CompilerFlagsCheck.cmake

This file was deleted.

16 changes: 0 additions & 16 deletions cmake/CopyFiles.cmake

This file was deleted.

24 changes: 0 additions & 24 deletions cmake/DetectDistro.cmake

This file was deleted.

10 changes: 0 additions & 10 deletions cmake/Subdirs.cmake

This file was deleted.

File renamed without changes.
80 changes: 80 additions & 0 deletions cmake/HalUtils.cmake → cmake/hal_cmake_tools.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -131,3 +131,83 @@ function(setup_output_directories)
message(VERBOSE "PLUGIN_LIBRARY_INSTALL_DIRECTORY: ${PLUGIN_LIBRARY_INSTALL_DIRECTORY}")
message(STATUS "")
endfunction()

include(CheckCXXCompilerFlag)
function(enable_cxx_compiler_flag_if_supported flag build_type)
string(FIND "${CMAKE_CXX_FLAGS}" "${flag}" flag_already_set)
if(flag_already_set EQUAL -1)
check_cxx_compiler_flag("${flag}" supports_${flag})
if(supports_${flag})
set(CMAKE_CXX_FLAGS${build_type} "${CMAKE_CXX_FLAGS${build_type}} ${flag}" PARENT_SCOPE)
endif()
unset(supports_${flag} CACHE)
endif()
unset(flag_already_set CACHE)
endfunction()

include(CheckCCompilerFlag)
function(enable_c_compiler_flag_if_supported flag build_type)
string(FIND "${CMAKE_C_FLAGS}" "${flag}" flag_already_set)
if(flag_already_set EQUAL -1)
check_c_compiler_flag("${flag}" supports_${flag})
if(supports_${flag})
set(CMAKE_C_FLAGS${build_type} "${CMAKE_C_FLAGS${build_type}} ${flag}" PARENT_SCOPE)
endif()
unset(supports_${flag} CACHE)
endif()
unset(flag_already_set CACHE)
endfunction()

# DetectDistro.cmake -- Detect Linux distribution
function(detect_distro)
message(STATUS "System is: ${CMAKE_SYSTEM_NAME}")
set(LINUX_DISTRO "" CACHE INTERNAL "")
set(LINUX_DISTRO_VERSION_NAME "" CACHE INTERNAL "")
if(LINUX)
# Detect Linux distribution (if possible)
execute_process(COMMAND "/usr/bin/lsb_release" "-is"
TIMEOUT 4
OUTPUT_VARIABLE LINUX_DISTRO
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE)
message(STATUS "Linux distro is: ${LINUX_DISTRO}")

# Detect Linux distribution (if possible)
execute_process(COMMAND "/usr/bin/lsb_release" "-cs"
TIMEOUT 4
OUTPUT_VARIABLE LINUX_DISTRO_VERSION_NAME
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE)
message(STATUS "Linux Distro version name is: ${LINUX_DISTRO_VERSION_NAME}")
endif()
execute_process(COMMAND uname -m COMMAND tr -d '\n' OUTPUT_VARIABLE ARCHITECTURE)
message(STATUS "System Arch is: ${ARCHITECTURE}")
endfunction()

MACRO(SUBDIRLIST result curdir)
FILE(GLOB children RELATIVE ${curdir} ${curdir}/*)
SET(dirlist "")
FOREACH(child ${children})
IF(IS_DIRECTORY ${curdir}/${child})
LIST(APPEND dirlist ${child})
ENDIF()
ENDFOREACH()
SET(${result} ${dirlist})
ENDMACRO()

macro(configure_files src_dir dst_dir extension)
message(STATUS "Configuring directory ${dst_dir}")
make_directory(${dst_dir})

file(GLOB files_to_copy RELATIVE ${src_dir} ${src_dir}/*.${extension})
foreach(file_to_copy ${files_to_copy})
set(file_path_to_copy ${src_dir}/${file_to_copy})
if(NOT IS_DIRECTORY ${file_path_to_copy})
message(STATUS "Configuring file ${file_to_copy}")
configure_file(
${file_path_to_copy}
${dst_dir}/${file_to_copy}
@ONLY)
endif(NOT IS_DIRECTORY ${file_path_to_copy})
endforeach(file_to_copy)
endmacro(configure_files)

0 comments on commit 4cd1555

Please sign in to comment.