diff --git a/CMakeLists.txt b/CMakeLists.txt index 48720706..ad5452f4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -44,10 +44,14 @@ else() message( FATAL_ERROR "Unrecognized compiler [${CMAKE_CXX_COMPILER_ID}]" ) endif() -### Add things for this project -add_subdirectory(src) -target_include_directories(polyscope PUBLIC "include") - ### Do anything needed for dependencies and bring their stuff in to scope add_subdirectory(deps) +### Add things for this project +add_subdirectory(src) + +### Build the demo viewer application +option(BUILD_POLYSCOPE_VIEWER "Build the viewer demo app." ON) +if(BUILD_POLYSCOPE_VIEWER) + add_subdirectory(src/viewer-app) +endif() \ No newline at end of file diff --git a/deps/CMakeLists.txt b/deps/CMakeLists.txt index 7c5db426..e5c2467f 100644 --- a/deps/CMakeLists.txt +++ b/deps/CMakeLists.txt @@ -8,7 +8,6 @@ set(GLFW_BUILD_DOCS OFF CACHE BOOL "" FORCE) set(GLFW_BUILD_TESTS OFF CACHE BOOL "" FORCE) set(GLFW_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE) add_subdirectory(glfw) -target_include_directories(polyscope PRIVATE "glfw/include") ## Imgui add_subdirectory(imgui) \ No newline at end of file diff --git a/deps/glad/CMakeLists.txt b/deps/glad/CMakeLists.txt index 3d27f161..0bd23df4 100644 --- a/deps/glad/CMakeLists.txt +++ b/deps/glad/CMakeLists.txt @@ -1,4 +1,3 @@ cmake_minimum_required(VERSION 2.8.9) -add_subdirectory(src) -target_include_directories(polyscope PRIVATE "include") \ No newline at end of file +add_subdirectory(src) \ No newline at end of file diff --git a/deps/glad/src/CMakeLists.txt b/deps/glad/src/CMakeLists.txt index 5196febb..bc54c10f 100644 --- a/deps/glad/src/CMakeLists.txt +++ b/deps/glad/src/CMakeLists.txt @@ -6,5 +6,4 @@ add_library( glad.c ) - -target_include_directories(glad PRIVATE "../include") \ No newline at end of file +target_include_directories(glad PRIVATE "../include") \ No newline at end of file diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 7a9e6570..0aef783d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -6,8 +6,8 @@ if (CMAKE_BINARY_DIR STREQUAL CMAKE_SOURCE_DIR) endif() # Collect all .cpp files in the subdirectories -file(GLOB_RECURSE SRCS *.cpp) -file(GLOB_RECURSE HEADS *.h *.hpp *.ipp) +file(GLOB SRCS *.cpp) +file(GLOB_RECURSE HEADS ../include *.h *.hpp *.ipp) # Create a single library for the project add_library( @@ -16,10 +16,22 @@ add_library( ${HEADS} ) +# Include settings +target_include_directories(polyscope PUBLIC "../include") +target_include_directories(polyscope PUBLIC "../deps/glfw/include") +target_include_directories(polyscope PRIVATE "../deps/glad/include") +target_include_directories(polyscope PRIVATE "../deps/glad/include") +target_include_directories(polyscope PUBLIC "../deps/imgui/imgui") + # Link settings -target_link_libraries(polyscope ${GLFW_LIBRARIES}) +target_link_libraries(polyscope imgui glfw ${GLFW_LIBRARIES}) if(APPLE) + find_library(cocoa_library Cocoa) + find_library(opengl_library OpenGL) + find_library(corevideo_library CoreVideo) + find_library(iokit_library IOKit) + target_link_libraries(polyscope ${cocoa_library} ${opengl_library} ${corevideo_library} ${iokit_library}) else() target_link_libraries(polyscope glad) endif() \ No newline at end of file diff --git a/src/polyscope.cpp b/src/polyscope.cpp index 3f065cf5..3579613f 100644 --- a/src/polyscope.cpp +++ b/src/polyscope.cpp @@ -458,8 +458,9 @@ void init() { if (!glfwInit()) { throw std::runtime_error(options::printPrefix + "ERROR: Failed to initialize glfw"); } + glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4); - glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2); + glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0); glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); #if __APPLE__ glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); diff --git a/src/viewer-app/CMakeLists.txt b/src/viewer-app/CMakeLists.txt new file mode 100644 index 00000000..ade6ccbe --- /dev/null +++ b/src/viewer-app/CMakeLists.txt @@ -0,0 +1,16 @@ +cmake_minimum_required(VERSION 2.8.9) + +# Maybe stop from CMAKEing in the wrong place +if (CMAKE_BINARY_DIR STREQUAL CMAKE_SOURCE_DIR) + message(FATAL_ERROR "Source and build directories cannot be the same. Go use the /build directory.") +endif() + +# Create a single library for the project +add_executable( + polyscopeviewer + viewer-app.cpp + ) + +# Link settings +message("polyscope val = ${polyscope}" ) +target_link_libraries(polyscopeviewer polyscope) \ No newline at end of file