aboutsummaryrefslogtreecommitdiff
path: root/tests/ExecuteAllModules/CMakeLists.txt
blob: be3ee67f746b82ca8c33ef83910478a57f4a0314 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# This file includes all *.cmake files, so they are all executed.
# As it is it doesn't test a lot.
# It makes sure that the modules don't contain basic syntax errors.
# It also makes sure that modules don't fail with an error if something
# wasn't found but REQUIRED was not given.
#
# I guess more things could be added, like checking whether variables are
# defined after running the modules (e.g. FOO_FOUND etc.).
project(ExecuteAllModules)
cmake_minimum_required(VERSION 2.8)

file(GLOB all_find_modules "${CMAKE_CURRENT_SOURCE_DIR}/../../find-modules/Find*cmake")
file(GLOB all_other_modules "${CMAKE_CURRENT_SOURCE_DIR}/../../modules/*cmake")

set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../modules)

foreach(module ${all_find_modules} ${all_other_modules})
  message(STATUS "module: ${module}")
  include("${module}")

  # get the "basename" of the package, so the existence of variables like
  # FOO_FOUND could be tested later on, Alex
  string(REGEX REPLACE ".+Find([^\\.]+)\\.cmake" "\\1" packageName "${module}")
  string(TOUPPER "${packageName}" packageNameUpper)

# disabled for now, since too many modules break:
#  if(NOT DEFINED ${packageNameUpper}_FOUND)
#    message(SEND_ERROR "${packageNameUpper}_FOUND not defined !")
#  endif(NOT DEFINED ${packageNameUpper}_FOUND)

endforeach(module ${all_modules})

add_executable(ExecuteAllModules main.c)