CMake: Wrap externs in TARGET conditionals

This commit is contained in:
Luke Street 2022-07-29 16:15:38 -04:00
parent 0da998450b
commit 74732a8cb3
1 changed files with 57 additions and 33 deletions

24
extern/CMakeLists.txt vendored
View File

@ -1,3 +1,4 @@
if (NOT TARGET dawn_native)
if (CMAKE_SYSTEM_NAME STREQUAL Windows) if (CMAKE_SYSTEM_NAME STREQUAL Windows)
set(DAWN_ENABLE_DESKTOP_GL ON CACHE BOOL "Enable compilation of the OpenGL backend" FORCE) set(DAWN_ENABLE_DESKTOP_GL ON CACHE BOOL "Enable compilation of the OpenGL backend" FORCE)
endif () endif ()
@ -16,7 +17,9 @@ else ()
target_compile_options(SPIRV-Tools-static PRIVATE -Wno-implicit-fallthrough) target_compile_options(SPIRV-Tools-static PRIVATE -Wno-implicit-fallthrough)
target_compile_options(SPIRV-Tools-opt PRIVATE -Wno-implicit-fallthrough) target_compile_options(SPIRV-Tools-opt PRIVATE -Wno-implicit-fallthrough)
endif () endif ()
endif ()
if (NOT TARGET SDL2-static)
if (WIN32) if (WIN32)
set(SDL_LIBC ON CACHE BOOL "Use the system C library" FORCE) set(SDL_LIBC ON CACHE BOOL "Use the system C library" FORCE)
endif () endif ()
@ -24,10 +27,16 @@ add_subdirectory(SDL EXCLUDE_FROM_ALL)
if (NOT MSVC) if (NOT MSVC)
target_compile_options(SDL2-static PRIVATE -Wno-implicit-fallthrough -Wno-shadow) target_compile_options(SDL2-static PRIVATE -Wno-implicit-fallthrough -Wno-shadow)
endif () endif ()
endif ()
if (NOT TARGET xxhash)
add_subdirectory(xxhash EXCLUDE_FROM_ALL) add_subdirectory(xxhash EXCLUDE_FROM_ALL)
endif ()
if (NOT TARGET fmt)
add_subdirectory(fmt EXCLUDE_FROM_ALL) add_subdirectory(fmt EXCLUDE_FROM_ALL)
endif ()
if (NOT TARGET imgui)
add_library(imgui add_library(imgui
imgui/imgui.cpp imgui/imgui.cpp
imgui/imgui_demo.cpp imgui/imgui_demo.cpp
@ -36,3 +45,18 @@ add_library(imgui
imgui/imgui_widgets.cpp imgui/imgui_widgets.cpp
imgui/misc/cpp/imgui_stdlib.cpp) imgui/misc/cpp/imgui_stdlib.cpp)
target_include_directories(imgui PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/imgui) target_include_directories(imgui PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/imgui)
if (CMAKE_COMPILER_IS_GNUCXX)
# currently explicitly ignored for clang in imgui code, but not gcc (yet)
target_compile_options(imgui PRIVATE -Wno-deprecated-enum-enum-conversion)
endif()
# Optional, replaces stb_freetype if available
find_package(Freetype)
# Permit disabling for macOS universal builds
option(IMGUI_USE_FREETYPE "Enable freetype with imgui" ON)
if (FREETYPE_FOUND AND IMGUI_USE_FREETYPE)
target_sources(imgui PRIVATE ../extern/imgui/misc/freetype/imgui_freetype.cpp)
target_compile_definitions(imgui PRIVATE IMGUI_ENABLE_FREETYPE)
target_link_libraries(imgui PRIVATE Freetype::Freetype)
endif ()
endif ()