Cmake: Move all find_packages to base CMakeLists.txt
authorTony Barbour <tony@LunarG.com>
Wed, 7 Dec 2016 23:13:35 +0000 (16:13 -0700)
committerTony Barbour <tony@LunarG.com>
Fri, 9 Dec 2016 18:48:58 +0000 (11:48 -0700)
Change-Id: Id27307788c7c230e75d620f1bf5470b1450289f2

CMakeLists.txt
demos/CMakeLists.txt
layers/CMakeLists.txt
loader/CMakeLists.txt

index 34aa8e5..0f59335 100644 (file)
@@ -12,27 +12,39 @@ set(API_NAME "Vulkan" CACHE STRING "API name to use when building")
 set(MAJOR "1")
 string(TOLOWER ${API_NAME} API_LOWERCASE)
 
+set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
 find_package(PythonInterp 3 REQUIRED)
 
 if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
+    include(FindPkgConfig)
     option(BUILD_WSI_XCB_SUPPORT "Build XCB WSI support" ON)
     option(BUILD_WSI_XLIB_SUPPORT "Build Xlib WSI support" ON)
     option(BUILD_WSI_WAYLAND_SUPPORT "Build Wayland WSI support" ON)
     option(BUILD_WSI_MIR_SUPPORT "Build Mir WSI support" ON)
     option(DEMOS_WSI_SELECTION "Select WSI to use to build demos" XCB)
-endif()
 
-set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
+    if (BUILD_WSI_XCB_SUPPORT)
+        find_package(XCB REQUIRED)
+    endif()
+
+    if (BUILD_WSI_XLIB_SUPPORT)
+        find_package(X11 REQUIRED)
+    endif()
+
+    if (BUILD_WSI_WAYLAND_SUPPORT)
+        find_package(Wayland REQUIRED)
+    endif()
+
+    if (BUILD_WSI_MIR_SUPPORT)
+        find_package(Mir REQUIRED)
+    endif()
+endif()
 
 set(SCRIPTS_DIR "${CMAKE_SOURCE_DIR}/scripts")
 
 # Header file for CMake settings
 include_directories("${PROJECT_SOURCE_DIR}/include")
 
-if(NOT WIN32)
-    include(FindPkgConfig)
-endif()
-
 if (CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "Clang")
     set(COMMON_COMPILE_FLAGS "-Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers")
     set(COMMON_COMPILE_FLAGS "${COMMON_COMPILE_FLAGS} -fno-strict-aliasing -fno-builtin-memcmp")
@@ -50,9 +62,6 @@ if(WIN32)
 endif()
 
 if(NOT WIN32)
-    if (BUILD_WSI_XCB_SUPPORT)
-        find_package(XCB REQUIRED)
-    endif()
     set (BUILDTGT_DIR build)
     set (BINDATA_DIR Bin)
     set (LIBSOURCE_DIR Lib)
index eff654b..9bf07e5 100644 (file)
@@ -12,7 +12,6 @@ elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
         if (NOT BUILD_WSI_XCB_SUPPORT)
             message( FATAL_ERROR "Selected XCB for demos build but not building Xcb support" )
         endif()
-        find_package(XCB REQUIRED)
         include_directories(${XCB_INCLUDE_DIRS})
         link_libraries(${XCB_LIBRARIES})
         add_definitions(-DVK_USE_PLATFORM_XCB_KHR)
@@ -20,7 +19,6 @@ elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
         if (NOT BUILD_WSI_XLIB_SUPPORT)
             message( FATAL_ERROR "Selected XLIB for demos build but not building Xlib support" )
         endif()
-        find_package(X11 REQUIRED)
         include_directories(${X11_INCLUDE_DIR})
         link_libraries(${X11_LIBRARIES})
         add_definitions(-DVK_USE_PLATFORM_XLIB_KHR)
@@ -28,7 +26,6 @@ elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
         if (NOT BUILD_WSI_WAYLAND_SUPPORT)
             message( FATAL_ERROR "Selected Wayland for demos build but not building Wayland support" )
         endif()
-        find_package(Wayland REQUIRED)
         include_directories(${WAYLAND_CLIENT_INCLUDE_DIR})
         link_libraries(${WAYLAND_CLIENT_LIBRARIES})
         add_definitions(-DVK_USE_PLATFORM_WAYLAND_KHR)
index e9cf066..a9b4428 100644 (file)
@@ -20,7 +20,6 @@ elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
 
     if (BUILD_WSI_MIR_SUPPORT)
         add_definitions(-DVK_USE_PLATFORM_MIR_KHR)
-        find_package(Mir REQUIRED)
         include_directories(${MIR_INCLUDE_DIR})
     endif()
 else()
index 63ee89a..095098a 100644 (file)
@@ -22,7 +22,6 @@ elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
 
     if (BUILD_WSI_MIR_SUPPORT)
         add_definitions(-DVK_USE_PLATFORM_MIR_KHR)
-        find_package(Mir REQUIRED)
         include_directories(${MIR_INCLUDE_DIR})
     endif()
 else()