0

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.

jammehcow
  • 155
  • 1
  • 1
  • 9
  • 2
    What cmake is supposed to do with shader files? Isn't `add_library` supposed to produce static or shared library? – user7860670 Sep 09 '17 at 22:00
  • If you just want to copy the shaders, have a look at https://stackoverflow.com/questions/34799916/cmake-copy-file-from-source-directory-to-binary-directory – camelCase Sep 09 '17 at 22:07

0 Answers0