CMakeLists.txt: move includes to the top, earlier pkg-config lookup

Move some of the common cmake includes to a location near the top of the
file. Lookup the pkg-config(1) utility before the construction of the
list of dependendencies.

Remaining subsequent includes are strictly conditional (backtrace), or
belong to different groups than source compilation (VCS revision, CPack).
This commit is contained in:
Gerhard Sittig 2018-05-06 11:29:19 +02:00
parent d56edfc6b1
commit 723ac3f8c5
1 changed files with 7 additions and 6 deletions

View File

@ -74,6 +74,13 @@ add_subdirectory(manual)
#= Dependencies
#-------------------------------------------------------------------------------
include(CheckCSourceCompiles)
include(CheckCXXSourceCompiles)
include(CMakePushCheckState)
include(memaccess)
find_package(PkgConfig)
list(APPEND PKGDEPS glib-2.0>=2.28.0)
list(APPEND PKGDEPS glibmm-2.4>=2.28.0)
@ -93,7 +100,6 @@ if(ANDROID)
list(APPEND PKGDEPS libsigrokandroidutils>=0.1.0)
endif()
find_package(PkgConfig)
pkg_check_modules(LIBSRCXX ${LIBSR_CXX_BINDING})
if(NOT LIBSRCXX_FOUND OR NOT LIBSRCXX_VERSION)
message(FATAL_ERROR "libsigrok C++ bindings missing, check libsigrok's 'configure' output (missing dependencies?)")
@ -151,8 +157,6 @@ find_package(Threads REQUIRED)
# Helper for checking for atomics
function(check_working_cxx_atomics varname additional_lib)
include(CheckCXXSourceCompiles)
include(CMakePushCheckState)
cmake_push_check_state()
set(CMAKE_REQUIRED_FLAGS "-std=c++11")
set(CMAKE_REQUIRED_LIBRARIES "${additional_lib}")
@ -191,8 +195,6 @@ endif()
# Check availability of features which depend on library versions.
# TODO Ideally use check_symbol_exists() instead, reduce boilerplate.
if(ENABLE_DECODE)
include(CheckCSourceCompiles)
include(CMakePushCheckState)
cmake_push_check_state()
set(CMAKE_REQUIRED_INCLUDES "${PKGDEPS_INCLUDE_DIRS}")
set(CMAKE_REQUIRED_LIBRARIES "sigrokdecode")
@ -215,7 +217,6 @@ endif()
#= System Introspection
#-------------------------------------------------------------------------------
include(memaccess)
memaccess_check_unaligned_le(HAVE_UNALIGNED_LITTLE_ENDIAN_ACCESS)
#===============================================================================