raygui/projects/CMake/CMakeLists.txt

77 lines
2.1 KiB
CMake
Raw Normal View History

cmake_minimum_required(VERSION 3.11)
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
project(raygui C)
# Config options
2021-11-06 10:00:29 -04:00
option(BUILD_RAYGUI_EXAMPLES "Build the examples." OFF)
# Force building examples if building in the root as standalone.
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
set(BUILD_RAYGUI_EXAMPLES TRUE)
endif()
# Directory Variables
set(RAYGUI_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/../..)
set(RAYGUI_SRC ${RAYGUI_ROOT}/src)
set(RAYGUI_EXAMPLES ${RAYGUI_ROOT}/examples)
# raygui
add_library(raygui INTERFACE)
file(GLOB sources ${RAYGUI_SRC}/*.h)
set(RAYGUI_HEADERS ${sources})
install(FILES
2020-05-18 13:32:22 -04:00
${RAYGUI_HEADERS} DESTINATION include
)
2020-05-18 13:32:22 -04:00
target_include_directories(raygui INTERFACE ${RAYGUI_SRC})
# Examples
if(${BUILD_RAYGUI_EXAMPLES})
2020-05-18 13:32:22 -04:00
find_package(Raylib)
2020-05-18 13:32:22 -04:00
# Get the sources together
set(example_dirs
animation_curve
2021-11-06 10:00:29 -04:00
controls_test_suite
2020-05-18 13:32:22 -04:00
custom_file_dialog
2023-03-19 06:13:17 -04:00
custom_sliders
2021-11-06 10:00:29 -04:00
image_exporter
2023-03-19 06:13:17 -04:00
image_importer_raw
2020-05-18 13:32:22 -04:00
portable_window
2021-11-06 10:00:29 -04:00
property_list
2020-05-18 13:32:22 -04:00
scroll_panel
2023-03-19 06:13:17 -04:00
style_selector
2020-05-18 13:32:22 -04:00
)
2020-05-18 13:32:22 -04:00
set(example_sources)
set(example_resources)
2020-05-18 13:32:22 -04:00
foreach(example_dir ${example_dirs})
# Get the .c files
file(GLOB sources ${RAYGUI_EXAMPLES}/${example_dir}/*.c)
list(APPEND example_sources ${sources})
2020-05-18 13:32:22 -04:00
# Any any resources
file(GLOB resources ${RAYGUI_EXAMPLES}/${example_dir}/resources/*)
list(APPEND example_resources ${resources})
endforeach()
2020-05-18 13:32:22 -04:00
# Do each example
foreach(example_source ${example_sources})
# Create the basename for the example
get_filename_component(example_name ${example_source} NAME)
string(REPLACE ".c" "${OUTPUT_EXT}" example_name ${example_name})
2020-05-18 13:32:22 -04:00
# Setup the example
add_executable(${example_name} ${example_source})
2020-05-18 13:32:22 -04:00
target_link_libraries(${example_name} PUBLIC raylib raygui)
2020-05-18 13:32:22 -04:00
string(REGEX MATCH ".*/.*/" resources_dir ${example_source})
string(APPEND resources_dir "resources")
endforeach()
2020-05-18 13:32:22 -04:00
# Copy all of the resource files to the destination
file(COPY ${example_resources} DESTINATION "resources/")
endif()