Skip to content

Commit

Permalink
Better handling for the library-vs.-framework issue for OpenGL and GLUT.
Browse files Browse the repository at this point in the history
Using find_library now which does the right thing regardless of which OS we're building on (I think - I haven't been able to test it on Linux yet).
  • Loading branch information
vilya committed Aug 24, 2010
1 parent a891898 commit 79cdf9c
Showing 1 changed file with 4 additions and 13 deletions.
17 changes: 4 additions & 13 deletions CMakeLists.txt
Expand Up @@ -5,6 +5,8 @@ cmake_minimum_required(VERSION 2.6)
# General build properties
file(GLOB VGL_SOURCES src/*.cpp thirdparty/*.c)
file(GLOB VGL_HEADERS src/*.h)
find_library(OpenGL_LIB OpenGL gl)
find_library(GLUT_LIB GLUT glut)

include_directories(src thirdparty /opt/local/include)
link_directories(/opt/local/lib)
Expand All @@ -13,33 +15,22 @@ link_directories(/opt/local/lib)
# Helper function which creates an example program.
function (example example_NAME)
add_executable(${example_NAME} example/${example_NAME}.cpp)
target_link_libraries(${example_NAME} vgl ${VGL_LIBS})
if (${APPLE})
set_target_properties(${example_NAME} PROPERTIES LINK_FLAGS "-framework OpenGL -framework GLUT")
endif(${APPLE})
target_link_libraries(${example_NAME} vgl)
install(TARGETS ${example_NAME} DESTINATION bin)
endfunction(example)

# Helper function which creates a test program.
function (test test_NAME)
add_executable(${test_NAME} test/${test_NAME}.cpp)
target_link_libraries(${test_NAME} vgl cppunit)
if (${APPLE})
set_target_properties(${test_NAME} PROPERTIES LINK_FLAGS "-framework OpenGL -framework GLUT")
endif(${APPLE})
install(TARGETS ${test_NAME} DESTINATION bin)
add_test(NAME run-${test_NAME} COMMAND ${test_NAME})
endfunction(test)


# The VGL shared library
add_library(vgl SHARED ${VGL_SOURCES} ${VGL_THIRDPARTY_SOURCES})
if (${APPLE})
target_link_libraries(vgl png jpeg tiff)
set_target_properties(vgl PROPERTIES LINK_FLAGS "-framework OpenGL -framework GLUT")
else(${APPLE})
target_link_libraries(vgl glut pthread png jpeg tiff)
endif(${APPLE})
target_link_libraries(vgl ${OpenGL_LIB} ${GLUT_LIB} pthread png jpeg tiff)
install(FILES ${VGL_HEADERS} DESTINATION dist/include)
install(TARGETS vgl LIBRARY DESTINATION dist/lib)

Expand Down

0 comments on commit 79cdf9c

Please sign in to comment.