diff --git a/CMakeLists.txt b/CMakeLists.txt index b022275..1dd400e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -54,27 +54,18 @@ elseif (${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU") set(LINKER_OPTIMIZED_OPTIONS ${LINKER_OPTIMIZED_OPTIONS} -fdevirtualize-at-ltrans) endif () -add_library(${PROJECT_NAME} STATIC) -target_sources(${PROJECT_NAME} - PRIVATE +add_library(${PROJECT_NAME} STATIC src/window.cpp + src/context_window.cpp src/opengl_context.cpp - - PUBLIC - FILE_SET public_headers - TYPE HEADERS - BASE_DIRS include/ - FILES include/opengl_context.hpp - include/window.hpp - include/context_window.hpp - include/basic_data.hpp ) target_precompile_headers(${PROJECT_NAME} PUBLIC include/window.hpp include/basic_data.hpp include/context_window.hpp) -target_compile_definitions(${PROJECT_NAME} - PUBLIC GLFW_INCLUDE_NONE - PRIVATE $<$,$>:_GLIBCXX_DEBUG> +target_include_directories(${PROJECT_NAME} + PUBLIC $ + INTERFACE $ ) +target_compile_definitions(${PROJECT_NAME} PUBLIC GLFW_INCLUDE_NONE PRIVATE $<$,$>:_GLIBCXX_DEBUG>) target_compile_options(${PROJECT_NAME} PUBLIC ${COMPILE_FLAGS} $<$:${COMPILE_OPTIMIZED_FLAGS}>) target_link_options(${PROJECT_NAME} PUBLIC ${LINKER_OPTIONS} $<$:${LINKER_OPTIMIZED_OPTIONS}>) target_link_libraries(${PROJECT_NAME} PUBLIC $<$:PkgConfig::Jemalloc> OpenGL::GL GLEW::GLEW glfw) @@ -91,8 +82,8 @@ install(TARGETS ${PROJECT_NAME} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - INCLUDES DESTINATION include - FILE_SET public_headers DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/windowGlfwGlLib" + INCLUDES DESTINATION include/windowGlfwGlLib + PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/windowGlfwGlLibTargets" ) install(EXPORT windowGlfwGlLibTargets @@ -106,6 +97,14 @@ configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/Config.cmake.in INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/windowGlfwGlLibTargets ) +install(FILES + include/window.hpp + include/basic_data.hpp + include/context_window.hpp + include/opengl_context.hpp + DESTINATION include/windowGlfwGlLib +) + install(FILES "${CMAKE_CURRENT_BINARY_DIR}/windowGlfwGlLibTargetsConfig.cmake" DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/windowGlfwGlLibTargets diff --git a/include/context_window.hpp b/include/context_window.hpp index bb2315c..b7fee92 100644 --- a/include/context_window.hpp +++ b/include/context_window.hpp @@ -11,17 +11,9 @@ namespace window { public: ContextWindow() noexcept = delete; - explicit ContextWindow(const GLFWerrorfun error_clbk) noexcept { - glfwSetErrorCallback(error_clbk); - if (glfwInit() == GLFW_FALSE) { - init = false; - } - init = true; - } + explicit ContextWindow(const GLFWerrorfun error_clbk) noexcept; - ~ContextWindow() noexcept { - glfwTerminate(); - } + ~ContextWindow() noexcept; [[nodiscard]] inline bool is_init() const { return init; } }; diff --git a/src/context_window.cpp b/src/context_window.cpp new file mode 100644 index 0000000..8f81541 --- /dev/null +++ b/src/context_window.cpp @@ -0,0 +1,16 @@ +#include "context_window.hpp" +#include + +namespace window { + ContextWindow::~ContextWindow() noexcept { + glfwTerminate(); + } + + ContextWindow::ContextWindow(const GLFWerrorfun error_clbk) noexcept { + glfwSetErrorCallback(error_clbk); + if (glfwInit() == GLFW_FALSE) { + init = false; + } + init = true; + } +} // window