commit 8263a521b235e8e4f113244d4d84a7861d520e8d Author: djairoh Date: Wed Jan 29 02:40:15 2025 +0100 updated cmake diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..18079ea --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "include/imgui"] + path = include/imgui + url = https://github.com/ocornut/imgui diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..9729a6d --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,53 @@ +cmake_minimum_required (VERSION 3.8) + +project ("colour-picker" LANGUAGES CXX C) + +#set(CMAKE_BUILD_TYPE Debug) + +# source files +file(GLOB_RECURSE SOURCE_FILES + ${CMAKE_SOURCE_DIR}/src/*.c + ${CMAKE_SOURCE_DIR}/src/*.cpp) + +# header files +file(GLOB HEADER_FILES + ${CMAKE_SOURCE_DIR}/src/*.h + ${CMAKE_SOURCE_DIR}/src/*.hpp) + +# imgui - note: could be done as a library as well but this was easier for now +file(GLOB IMGUI_FILES + ${CMAKE_SOURCE_DIR}/include/imgui/*.h + ${CMAKE_SOURCE_DIR}/include/imgui/*.cpp + ${CMAKE_SOURCE_DIR}/include/imgui/backends/imgui_impl_opengl3.* + ${CMAKE_SOURCE_DIR}/include/imgui/backends/imgui_impl_glfw.*) + +include_directories(${CMAKE_SOURCE_DIR}/include/imgui) + +add_executable(${PROJECT_NAME} ${HEADER_FILES} ${SOURCE_FILES} ${IMGUI_FILES}) + +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/") + +# Package management + +# OpenGL +set(OpenGL_GL_PREFERENCE GLVND) +find_package(OpenGL REQUIRED) + +# GLFW +find_package(GLFW3 REQUIRED) +message(STATUS "Found GLFW3 in ${GLFW3_INCLUDE_DIR}") + +# GLAD +# add_library(GLAD "thirdparty/glad.c") + +set(LIBS ${GLFW3_LIBRARY} ${OPENGL_LIBRARY} ${CMAKE_DL_LIBS}) +# set(LIBS ${GLFW3_LIBRARY} ${OPENGL_LIBRARY} GLAD ${CMAKE_DL_LIBS} ${CUDA_LIBRARIES} ${NETCDF_LIB}) + +include_directories( + "${CMAKE_SOURCE_DIR}/src" + "${CMAKE_SOURCE_DIR}/include" +) + +target_link_libraries(${PROJECT_NAME} ${LIBS}) + + diff --git a/cmake/FindGLFW3.cmake b/cmake/FindGLFW3.cmake new file mode 100644 index 0000000..d63304c --- /dev/null +++ b/cmake/FindGLFW3.cmake @@ -0,0 +1,49 @@ +# Locate the glfw3 library +# +# This module defines the following variables: +# +# GLFW3_LIBRARY the name of the library; +# GLFW3_INCLUDE_DIR where to find glfw include files. +# GLFW3_FOUND true if both the GLFW3_LIBRARY and GLFW3_INCLUDE_DIR have been found. +# +# To help locate the library and include file, you can define a +# variable called GLFW3_ROOT which points to the root of the glfw library +# installation. +# +# default search dirs +# +# Cmake file from: https://github.com/daw42/glslcookbook + +set( _glfw3_HEADER_SEARCH_DIRS +"/usr/include" +"/usr/local/include" +"${CMAKE_SOURCE_DIR}/include" +"C:/Program Files (x86)/glfw/include" ) +set( _glfw3_LIB_SEARCH_DIRS +"/usr/lib" +"/usr/local/lib" +"${CMAKE_SOURCE_DIR}/lib" +"C:/Program Files (x86)/glfw/lib-msvc110" ) + +# Check environment for root search directory +set( _glfw3_ENV_ROOT $ENV{GLFW3_ROOT} ) +if( NOT GLFW3_ROOT AND _glfw3_ENV_ROOT ) + set(GLFW3_ROOT ${_glfw3_ENV_ROOT} ) +endif() + +# Put user specified location at beginning of search +if( GLFW3_ROOT ) + list( INSERT _glfw3_HEADER_SEARCH_DIRS 0 "${GLFW3_ROOT}/include" ) + list( INSERT _glfw3_LIB_SEARCH_DIRS 0 "${GLFW3_ROOT}/lib" ) +endif() + +# Search for the header +FIND_PATH(GLFW3_INCLUDE_DIR "GLFW/glfw3.h" +PATHS ${_glfw3_HEADER_SEARCH_DIRS} ) + +# Search for the library +FIND_LIBRARY(GLFW3_LIBRARY NAMES glfw3 glfw +PATHS ${_glfw3_LIB_SEARCH_DIRS} ) +INCLUDE(FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(GLFW3 DEFAULT_MSG +GLFW3_LIBRARY GLFW3_INCLUDE_DIR) diff --git a/include/imgui b/include/imgui new file mode 160000 index 0000000..4230e98 --- /dev/null +++ b/include/imgui @@ -0,0 +1 @@ +Subproject commit 4230e98720357c5e770e3a078a9e4d09f0923279