Clean up CMake files (#90)

This commit is contained in:
Rob Loach
2020-05-18 13:32:22 -04:00
committed by GitHub
parent 65bad19e26
commit 3e61557f25
2 changed files with 52 additions and 53 deletions

View File

@ -16,56 +16,55 @@ add_library(raygui INTERFACE)
file(GLOB sources ${RAYGUI_SRC}/*.h) file(GLOB sources ${RAYGUI_SRC}/*.h)
set(RAYGUI_HEADERS ${sources}) set(RAYGUI_HEADERS ${sources})
install(FILES install(FILES
${RAYGUI_HEADERS} DESTINATION include ${RAYGUI_HEADERS} DESTINATION include
) )
target_include_directories(raygui INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/../../src) target_include_directories(raygui INTERFACE ${RAYGUI_SRC})
# Examples # Examples
if(${BUILD_RAYGUI_EXAMPLES}) if(${BUILD_RAYGUI_EXAMPLES})
find_package(Raylib) find_package(Raylib)
# Get the sources together # Get the sources together
set(example_dirs set(example_dirs
custom_file_dialog custom_file_dialog
image_raw_importer image_raw_importer
portable_window portable_window
scroll_panel scroll_panel
text_box_selection text_box_selection
controls_test_suite controls_test_suite
image_exporter image_exporter
property_list property_list
standalone text_editor
text_editor )
)
set(example_sources) set(example_sources)
set(example_resources) set(example_resources)
foreach(example_dir ${example_dirs}) foreach(example_dir ${example_dirs})
# Get the .c files # Get the .c files
file(GLOB sources ${RAYGUI_EXAMPLES}/${example_dir}/*.c) file(GLOB sources ${RAYGUI_EXAMPLES}/${example_dir}/*.c)
list(APPEND example_sources ${sources}) list(APPEND example_sources ${sources})
# Any any resources # Any any resources
file(GLOB resources ${RAYGUI_EXAMPLES}/${example_dir}/resources/*) file(GLOB resources ${RAYGUI_EXAMPLES}/${example_dir}/resources/*)
list(APPEND example_resources ${resources}) list(APPEND example_resources ${resources})
endforeach() endforeach()
# Do each example # Do each example
foreach(example_source ${example_sources}) foreach(example_source ${example_sources})
# Create the basename for the example # Create the basename for the example
get_filename_component(example_name ${example_source} NAME) get_filename_component(example_name ${example_source} NAME)
string(REPLACE ".c" "${OUTPUT_EXT}" example_name ${example_name}) string(REPLACE ".c" "${OUTPUT_EXT}" example_name ${example_name})
# Setup the example # Setup the example
add_executable(${example_name} ${example_source}) add_executable(${example_name} ${example_source})
target_link_libraries(${example_name} PUBLIC raylib raygui) target_link_libraries(${example_name} PUBLIC raylib raygui)
string(REGEX MATCH ".*/.*/" resources_dir ${example_source}) string(REGEX MATCH ".*/.*/" resources_dir ${example_source})
string(APPEND resources_dir "resources") string(APPEND resources_dir "resources")
endforeach() endforeach()
# Copy all of the resource files to the destination # Copy all of the resource files to the destination
file(COPY ${example_resources} DESTINATION "resources/") file(COPY ${example_resources} DESTINATION "resources/")
endif() endif()

View File

@ -1,17 +1,17 @@
find_package(raylib 3.0.0 QUIET CONFIG) find_package(raylib 3.0.0 QUIET CONFIG)
if (NOT raylib_FOUND) if (NOT raylib_FOUND)
include(FetchContent) include(FetchContent)
FetchContent_Declare( FetchContent_Declare(
raylib raylib
GIT_REPOSITORY https://github.com/raysan5/raylib.git GIT_REPOSITORY https://github.com/raysan5/raylib.git
GIT_TAG 6a8b1079c13b7d5e1bddc0ecc86ad7e16fc2556d GIT_TAG df5c522049ddd82fba048a6bd069338999729d6a
) )
FetchContent_GetProperties(raylib) FetchContent_GetProperties(raylib)
if (NOT raylib_POPULATED) # Have we downloaded raylib yet? if (NOT raylib_POPULATED) # Have we downloaded raylib yet?
set(FETCHCONTENT_QUIET NO) set(FETCHCONTENT_QUIET NO)
FetchContent_Populate(raylib) FetchContent_Populate(raylib)
set(BUILD_EXAMPLES OFF CACHE BOOL "" FORCE) # don't build the supplied examples set(BUILD_EXAMPLES OFF CACHE BOOL "" FORCE) # don't build the supplied examples
set(BUILD_GAMES OFF CACHE BOOL "" FORCE) # or games set(BUILD_GAMES OFF CACHE BOOL "" FORCE) # or games
add_subdirectory(${raylib_SOURCE_DIR} ${raylib_BINARY_DIR}) add_subdirectory(${raylib_SOURCE_DIR} ${raylib_BINARY_DIR})
endif() endif()
endif() endif()