mirror of
https://github.com/lubosz/overte.git
synced 2025-04-27 13:55:26 +02:00
have cmake copy dlls for glut and glew beside executable
This commit is contained in:
parent
5452b81d58
commit
23249866f7
3 changed files with 46 additions and 31 deletions
|
@ -5,6 +5,7 @@
|
|||
# GLEW_FOUND
|
||||
# GLEW_INCLUDE_DIRS
|
||||
# GLEW_LIBRARY
|
||||
# GLEW_WIN_DLL
|
||||
#
|
||||
|
||||
# Created on 2/6/2014 by Stephen Birarda
|
||||
|
@ -27,6 +28,7 @@ else ()
|
|||
endif()
|
||||
|
||||
find_library(GLEW_LIBRARY glew32 PATH_SUFFIXES "lib/Release/${WIN_ARCH_DIR}" HINTS ${WIN_GLEW_SEARCH_DIRS})
|
||||
find_library(GLEW_WIN_DLL glew32 PATH_SUFFIXES "bin/Release/${WIN_ARCH_DIR}" HINTS ${WIN_GLEW_SEARCH_DIRS})
|
||||
endif ()
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
# GLUT_FOUND
|
||||
# GLUT_INCLUDE_DIR
|
||||
# GLUT_LIBRARIES
|
||||
# GLUT_WIN_DLL - Optionally defined for Win32
|
||||
#
|
||||
# Created on 2/6/2014 by Stephen Birarda
|
||||
#
|
||||
|
@ -18,12 +19,11 @@ else ()
|
|||
find_path(GLUT_INCLUDE_DIR GL/glut.h PATH_SUFFIXES include HINTS ${WIN_GLUT_SEARCH_DIRS})
|
||||
|
||||
if (CMAKE_CL_64)
|
||||
set(WIN_ARCH_DIR "lib/x64")
|
||||
else()
|
||||
set(WIN_ARCH_DIR "lib")
|
||||
set(WIN_ARCH_DIR "x64")
|
||||
endif()
|
||||
|
||||
find_library(GLUT_glut_LIBRARY freeglut PATH_SUFFIXES ${WIN_ARCH_DIR} HINTS ${WIN_GLUT_SEARCH_DIRS})
|
||||
find_library(GLUT_glut_LIBRARY freeglut PATH_SUFFIXES lib/${WIN_ARCH_DIR} HINTS ${WIN_GLUT_SEARCH_DIRS})
|
||||
find_library(GLUT_WIN_DLL freeglut PATH_SUFFIXES bin/${WIN_ARCH_DIR} HINTS ${WIN_GLUT_SEARCH_DIRS})
|
||||
else ()
|
||||
find_path(GLUT_INCLUDE_DIR GL/glut.h
|
||||
"${GLUT_LOCATION}/include"
|
||||
|
|
|
@ -93,17 +93,6 @@ if (APPLE)
|
|||
endforeach()
|
||||
|
||||
SET(INTERFACE_SRCS ${INTERFACE_SRCS} "${CMAKE_CURRENT_SOURCE_DIR}/interface.icns")
|
||||
elseif()
|
||||
# remove and then copy the resources files beside the executable
|
||||
add_custom_command(TARGET ${TARGET_NAME} POST_BUILD
|
||||
COMMAND "${CMAKE_COMMAND}" -E remove_directory
|
||||
$<TARGET_FILE_DIR:${TARGET_NAME}>/resources
|
||||
)
|
||||
add_custom_command(TARGET ${TARGET_NAME} POST_BUILD
|
||||
COMMAND "${CMAKE_COMMAND}" -E copy_directory
|
||||
"${PROJECT_SOURCE_DIR}/resources"
|
||||
$<TARGET_FILE_DIR:${TARGET_NAME}>/resources
|
||||
)
|
||||
endif()
|
||||
|
||||
# create the executable, make it a bundle on OS X
|
||||
|
@ -212,21 +201,45 @@ if (APPLE)
|
|||
RUNTIME DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/install" COMPONENT Runtime
|
||||
)
|
||||
else (APPLE)
|
||||
find_package(OpenGL REQUIRED)
|
||||
find_package(GLUT REQUIRED)
|
||||
# remove and then copy the resources files beside the executable
|
||||
add_custom_command(TARGET ${TARGET_NAME} POST_BUILD
|
||||
COMMAND "${CMAKE_COMMAND}" -E remove_directory
|
||||
$<TARGET_FILE_DIR:${TARGET_NAME}>/resources
|
||||
)
|
||||
add_custom_command(TARGET ${TARGET_NAME} POST_BUILD
|
||||
COMMAND "${CMAKE_COMMAND}" -E copy_directory
|
||||
"${PROJECT_SOURCE_DIR}/resources"
|
||||
$<TARGET_FILE_DIR:${TARGET_NAME}>/resources
|
||||
)
|
||||
|
||||
include_directories(SYSTEM "${GLUT_INCLUDE_DIR}")
|
||||
|
||||
if (${OPENGL_INCLUDE_DIR})
|
||||
include_directories(SYSTEM "${OPENGL_INCLUDE_DIR}")
|
||||
endif ()
|
||||
|
||||
target_link_libraries(${TARGET_NAME} "${OPENGL_LIBRARY}" "${GLUT_LIBRARIES}")
|
||||
|
||||
# link target to external libraries
|
||||
if (WIN32)
|
||||
find_package(GLEW REQUIRED)
|
||||
include_directories(${GLEW_INCLUDE_DIRS})
|
||||
target_link_libraries(${TARGET_NAME} "${GLEW_LIBRARY}" wsock32.lib opengl32.lib)
|
||||
endif()
|
||||
find_package(OpenGL REQUIRED)
|
||||
find_package(GLUT REQUIRED)
|
||||
|
||||
include_directories(SYSTEM "${GLUT_INCLUDE_DIR}")
|
||||
|
||||
if (${OPENGL_INCLUDE_DIR})
|
||||
include_directories(SYSTEM "${OPENGL_INCLUDE_DIR}")
|
||||
endif ()
|
||||
|
||||
target_link_libraries(${TARGET_NAME} "${OPENGL_LIBRARY}" "${GLUT_LIBRARIES}")
|
||||
|
||||
# link target to external libraries
|
||||
if (WIN32)
|
||||
find_package(GLEW REQUIRED)
|
||||
include_directories(${GLEW_INCLUDE_DIRS})
|
||||
target_link_libraries(${TARGET_NAME} "${GLEW_LIBRARY}" wsock32.lib opengl32.lib)
|
||||
|
||||
# have CMake copy the dlls for GLUT and GLEW as a post build step
|
||||
add_custom_command(TARGET ${TARGET_NAME} POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||
${GLUT_WIN_DLL}
|
||||
$<TARGET_FILE_DIR:${TARGET_NAME}>
|
||||
)
|
||||
|
||||
add_custom_command(TARGET ${TARGET_NAME} POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||
${GLEW_WIN_DLL}
|
||||
$<TARGET_FILE_DIR:${TARGET_NAME}>
|
||||
)
|
||||
endif()
|
||||
endif (APPLE)
|
||||
|
|
Loading…
Reference in a new issue