Skip to content

Commit

Permalink
CMakeLists.txt better find_package for GLFW3
Browse files Browse the repository at this point in the history
  • Loading branch information
sonoro1234 committed Jun 30, 2018
1 parent 8e7ce02 commit b539a6c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 26 deletions.
43 changes: 18 additions & 25 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ set(IMGUI_SOURCES ./cimgui/generator/generated/cimgui_auto.cpp ./cimgui/imgui/im
set(IMGUI_LIBRARIES )

if (WIN32)
add_definitions("-DIMGUI_IMPL_API=extern \"C\" __declspec\(dllexport\)")
add_definitions("-DIMGUI_IMPL_API=extern \"C\" __declspec\(dllexport\)")
else(WIN32)
add_definitions("-DIMGUI_IMPL_API=extern \"C\" ")
add_definitions("-DIMGUI_IMPL_API=extern \"C\" ")
endif(WIN32)

#optional adding implementations
Expand All @@ -23,43 +23,36 @@ option(IMPL_OPENGL2 "add OPENGL2 implementation" OFF)
option(IMPL_OPENGL3 "add OPENGL3 implementation" OFF)

if(IMPL_GLFW)
list(APPEND IMGUI_SOURCES ./cimgui/imgui/examples/imgui_impl_glfw.cpp)

if (WIN32)
FIND_LIBRARY(GLFW_LIBRARY NAMES glfw3.dll PATHS ${GLFW_PATH})
include_directories(cimgui/imgui/examples/libs/glfw/include)
else(WIN32)
message(WARNING "do the correct things to find GLFW on linux or osx")
endif(WIN32)

list(APPEND IMGUI_LIBRARIES ${GLFW_LIBRARY})
list(APPEND IMGUI_SOURCES ./cimgui/imgui/examples/imgui_impl_glfw.cpp)
FIND_PACKAGE(glfw3 3.2 REQUIRED PATHS ${GLFW_PATH})
list(APPEND IMGUI_LIBRARIES glfw)
endif(IMPL_GLFW)

if(IMPL_SDL)
list(APPEND IMGUI_SOURCES ./cimgui/imgui/examples/imgui_impl_sdl.cpp)
include_directories(${SDL_INCLUDE})
list(APPEND IMGUI_LIBRARIES ${SDL_LIBRARY})
list(APPEND IMGUI_SOURCES ./cimgui/imgui/examples/imgui_impl_sdl.cpp)
include_directories(${SDL_INCLUDE})
list(APPEND IMGUI_LIBRARIES ${SDL_LIBRARY})
endif(IMPL_SDL)

if(IMPL_OPENGL3)
list(APPEND IMGUI_SOURCES ./cimgui/imgui/examples/imgui_impl_opengl3.cpp
./cimgui/imgui/examples/libs/gl3w/GL/gl3w.c)
list(APPEND IMGUI_SOURCES ./extras/cimgui_extras.cpp)
include_directories(cimgui/imgui/examples/libs/gl3w)
list(APPEND IMGUI_LIBRARIES opengl32)
list(APPEND IMGUI_SOURCES ./cimgui/imgui/examples/imgui_impl_opengl3.cpp
./cimgui/imgui/examples/libs/gl3w/GL/gl3w.c)
list(APPEND IMGUI_SOURCES ./extras/cimgui_extras.cpp)
include_directories(cimgui/imgui/examples/libs/gl3w)
list(APPEND IMGUI_LIBRARIES opengl32)
endif(IMPL_OPENGL3)

if(IMPL_OPENGL2)
list(APPEND IMGUI_SOURCES ./cimgui/imgui/examples/imgui_impl_opengl2.cpp)
list(APPEND IMGUI_LIBRARIES opengl32)
list(APPEND IMGUI_SOURCES ./cimgui/imgui/examples/imgui_impl_opengl2.cpp)
list(APPEND IMGUI_LIBRARIES opengl32)
endif(IMPL_OPENGL2)

if(IMPL_EXTRAS)
add_compile_options(-std=c++11)
list(APPEND IMGUI_SOURCES ./extras/impl_glfw3/imgui_impl_glfw_gl3.cpp
add_compile_options(-std=c++11)
list(APPEND IMGUI_SOURCES ./extras/impl_glfw3/imgui_impl_glfw_gl3.cpp
./extras/knob.cpp ./extras/curve.cpp ./extras/Bezier.cpp)
endif(IMPL_EXTRAS)

#add library and link
add_library(cimgui SHARED ${IMGUI_SOURCES})
target_link_libraries(cimgui ${IMGUI_LIBRARIES})
target_link_libraries(cimgui ${IMGUI_LIBRARIES})
2 changes: 1 addition & 1 deletion build/init_cmake_glfw.bat
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
set PATH=%PATH%;C:\mingw32\bin;C:\cmake-3.6.0\bin

cmake -G"MinGW Makefiles" -DCMAKE_BUILD_TYPE=RelWithDebInfo -DGLFW_PATH="c:/luaGL" -DIMPL_GLFW=yes -DIMPL_OPENGL2=yes -DIMPL_OPENGL3=yes -DIMPL_EXTRAS=yes ../luajit-imgui
cmake -G"MinGW Makefiles" -DCMAKE_BUILD_TYPE=RelWithDebInfo -DGLFW_PATH="../buildGLFW/install" -DIMPL_GLFW=yes -DIMPL_OPENGL2=yes -DIMPL_OPENGL3=yes -DIMPL_EXTRAS=yes ../luajit-imgui

cmd /k

0 comments on commit b539a6c

Please sign in to comment.