I've been messing with OpenGL in C++ for a week or so and have started using files for my shaders. Note that they live in ./shaders/core.*
either ending in .frag
or .vert
.
Using CMake I thought it would be as easy as add_subdirectory(shaders)
and include a CMakeLists.txt
in the subdirectory. I was wrong.
My current root CMakeLists.txt:
cmake_minimum_required(VERSION 3.7)
project(OpenGL)
set(CMAKE_CXX_STANDARD 14)
find_package(OpenGL REQUIRED)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -framework OpenGL -lglfw -lglew")
add_subdirectory(shaders)
set(SOURCE_FILES
main.cpp
shader.h
)
add_executable(OpenGL ${SOURCE_FILES})
And the ./shaders/CMakeLists.txt
:
set(SAHDERS_SOURCE_FILES
core.frag
core.vert
)
set_source_files_properties(${SHADERS_SOURCE_FILES} PROPERTIES HEADER_FILE_ONLY TRUE)
add_library(shaders ${SHADERS_SOURCE_FILES})
The current setup gave me some hope on something I was going to give up on as it finally generated a shaders.dir
in the cmake-build-debug
folder, but didn't add the shaders files.
Tried so many things and gotten pretty much nowhere. If someone could guide me on the right track for this it would be much appreciated.