From fa8b958a91f63e13ebcfd0ff33b7eaaa2bcefa64 Mon Sep 17 00:00:00 2001 From: Rob Loach Date: Fri, 1 May 2020 07:31:15 -0400 Subject: [PATCH] Move CMake files to projects/CMake (#87) Fixes #86 --- CMakeLists.txt | 16 ----- examples/CMakeLists.txt | 46 ------------ projects/CMake/CMakeLists.txt | 71 +++++++++++++++++++ projects/CMake/README.md | 13 ++++ .../CMake/cmake}/FindRaylib.cmake | 0 src/CMakeLists.txt | 10 --- 6 files changed, 84 insertions(+), 72 deletions(-) delete mode 100644 CMakeLists.txt delete mode 100644 examples/CMakeLists.txt create mode 100644 projects/CMake/CMakeLists.txt create mode 100644 projects/CMake/README.md rename {cmake => projects/CMake/cmake}/FindRaylib.cmake (100%) delete mode 100644 src/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt deleted file mode 100644 index c04d7e4..0000000 --- a/CMakeLists.txt +++ /dev/null @@ -1,16 +0,0 @@ -cmake_minimum_required(VERSION 3.11) -set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake) - -project(raygui C) - -# Config options -option(BUILD_EXAMPLES "Build the examples." ON) - -add_subdirectory(src) - -if (${BUILD_EXAMPLES}) - add_subdirectory(examples) -endif() - -# TODO: Add automated testing. -# enable_testing() \ No newline at end of file diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt deleted file mode 100644 index ed75fb3..0000000 --- a/examples/CMakeLists.txt +++ /dev/null @@ -1,46 +0,0 @@ -find_package(Raylib) - -# Get the sources together -set(example_dirs - custom_file_dialog - image_raw_importer - portable_window - scroll_panel - text_box_selection - controls_test_suite - image_exporter - property_list - standalone - text_editor -) - -set(example_sources) -set(example_resources) - -foreach(example_dir ${example_dirs}) - # Get the .c files - file(GLOB sources ${example_dir}/*.c) - list(APPEND example_sources ${sources}) - - # Any any resources - file(GLOB resources ${example_dir}/resources/*) - list(APPEND example_resources ${resources}) -endforeach() - -# 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}) - - # Setup the example - add_executable(${example_name} ${example_source}) - - target_link_libraries(${example_name} PUBLIC raylib raygui) - - string(REGEX MATCH ".*/.*/" resources_dir ${example_source}) - string(APPEND resources_dir "resources") -endforeach() - -# Copy all of the resource files to the destination -file(COPY ${example_resources} DESTINATION "resources/") \ No newline at end of file diff --git a/projects/CMake/CMakeLists.txt b/projects/CMake/CMakeLists.txt new file mode 100644 index 0000000..15b6fc8 --- /dev/null +++ b/projects/CMake/CMakeLists.txt @@ -0,0 +1,71 @@ +cmake_minimum_required(VERSION 3.11) +set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake) + +project(raygui C) + +# Config options +option(BUILD_RAYGUI_EXAMPLES "Build the examples." ON) + +# 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 + ${RAYGUI_HEADERS} DESTINATION include +) +target_include_directories(raygui INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/../../src) + +# Examples +if(${BUILD_RAYGUI_EXAMPLES}) + find_package(Raylib) + + # Get the sources together + set(example_dirs + custom_file_dialog + image_raw_importer + portable_window + scroll_panel + text_box_selection + controls_test_suite + image_exporter + property_list + standalone + text_editor + ) + + set(example_sources) + set(example_resources) + + foreach(example_dir ${example_dirs}) + # Get the .c files + file(GLOB sources ${RAYGUI_EXAMPLES}/${example_dir}/*.c) + list(APPEND example_sources ${sources}) + + # Any any resources + file(GLOB resources ${RAYGUI_EXAMPLES}/${example_dir}/resources/*) + list(APPEND example_resources ${resources}) + endforeach() + + # 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}) + + # Setup the example + add_executable(${example_name} ${example_source}) + + target_link_libraries(${example_name} PUBLIC raylib raygui) + + string(REGEX MATCH ".*/.*/" resources_dir ${example_source}) + string(APPEND resources_dir "resources") + endforeach() + + # Copy all of the resource files to the destination + file(COPY ${example_resources} DESTINATION "resources/") +endif() \ No newline at end of file diff --git a/projects/CMake/README.md b/projects/CMake/README.md new file mode 100644 index 0000000..b384a8d --- /dev/null +++ b/projects/CMake/README.md @@ -0,0 +1,13 @@ +# raygui CMake Definitions + +This provides CMake definition files for raygui. + +## Usage + +``` +cd projects/CMake +mkdir build +cd build +cmake .. +make +``` \ No newline at end of file diff --git a/cmake/FindRaylib.cmake b/projects/CMake/cmake/FindRaylib.cmake similarity index 100% rename from cmake/FindRaylib.cmake rename to projects/CMake/cmake/FindRaylib.cmake diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt deleted file mode 100644 index f6cef6b..0000000 --- a/src/CMakeLists.txt +++ /dev/null @@ -1,10 +0,0 @@ -add_library(raygui INTERFACE) - -file(GLOB sources *.h) -set(RAYGUI_HEADERS ${sources}) - -install(FILES - ${RAYGUI_HEADERS} DESTINATION include -) - -target_include_directories(raygui INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/)