Skip to content

Commit

Permalink
basic example works
Browse files Browse the repository at this point in the history
  • Loading branch information
nmwsharp committed Nov 21, 2017
1 parent facf50e commit 4167f5e
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 13 deletions.
12 changes: 8 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
1 change: 0 additions & 1 deletion deps/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
3 changes: 1 addition & 2 deletions deps/glad/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
cmake_minimum_required(VERSION 2.8.9)

add_subdirectory(src)
target_include_directories(polyscope PRIVATE "include")
add_subdirectory(src)
3 changes: 1 addition & 2 deletions deps/glad/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,4 @@ add_library(
glad.c
)


target_include_directories(glad PRIVATE "../include")
target_include_directories(glad PRIVATE "../include")
18 changes: 15 additions & 3 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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()
3 changes: 2 additions & 1 deletion src/polyscope.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
16 changes: 16 additions & 0 deletions src/viewer-app/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit 4167f5e

Please sign in to comment.