mirror of https://github.com/bjornbytes/lovr.git
CMake wasn't that bad;
This commit is contained in:
parent
d28c8e4442
commit
440857a2d7
|
@ -1,3 +1,4 @@
|
|||
.tup
|
||||
lovr
|
||||
build
|
||||
src/obj
|
||||
|
|
|
@ -0,0 +1,56 @@
|
|||
cmake_minimum_required(VERSION 3.0.0)
|
||||
project(lovr)
|
||||
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
|
||||
file(GLOB SOURCES src/*.c)
|
||||
if(APPLE)
|
||||
set(LUAJIT_OSX_MAGIC "-pagezero_size 10000 -image_base 100000000")
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${LUAJIT_OSX_MAGIC}")
|
||||
endif()
|
||||
|
||||
add_executable(lovr ${SOURCES})
|
||||
|
||||
# LuaJIT
|
||||
find_package(LuaJIT REQUIRED)
|
||||
if(LuaJIT_FOUND)
|
||||
include_directories(${LUA_INCLUDE_DIR})
|
||||
target_link_libraries(lovr ${LUA_LIBRARIES})
|
||||
else()
|
||||
message(STATUS "LuaJIT not found")
|
||||
endif()
|
||||
|
||||
# Assimp
|
||||
find_package(assimp REQUIRED)
|
||||
if(assimp_FOUND)
|
||||
include_directories(${assimp_INCLUDE_DIRS})
|
||||
target_link_libraries(lovr ${assimp_LIBRARIES})
|
||||
else()
|
||||
message(STATUS "assimp not found")
|
||||
endif()
|
||||
|
||||
# GLFW
|
||||
find_package(GLFW REQUIRED)
|
||||
if(GLFW_FOUND)
|
||||
include_directories(${GLFW_INCLUDE_DIR})
|
||||
target_link_libraries(lovr ${GLFW_LIBRARIES})
|
||||
else()
|
||||
message(STATUS "GLFW not found")
|
||||
endif()
|
||||
|
||||
# OSVR FIXME
|
||||
find_library(OSVR_CLIENTKIT_LIBRARY NAMES osvrClientKit)
|
||||
find_library(OSVR_CLIENT_LIBRARY NAMES osvrClient)
|
||||
find_path(OSVR_INCLUDE_DIR NAMES osvr/ClientKit/ClientKit.h)
|
||||
|
||||
if(OSVR_INCLUDE_DIR AND OSVR_CLIENTKIT_LIBRARY AND OSVR_CLIENT_LIBRARY)
|
||||
include_directories(${OSVR_INCLUDE_DIR})
|
||||
target_link_libraries(lovr ${OSVR_CLIENT_LIBRARY})
|
||||
target_link_libraries(lovr ${OSVR_CLIENTKIT_LIBRARY})
|
||||
endif()
|
||||
|
||||
# OpenGL
|
||||
find_package(OpenGL REQUIRED)
|
||||
if(OPENGL_FOUND)
|
||||
include_directories(${OPENGL_INCLUDE_DIR})
|
||||
target_link_libraries(lovr ${OPENGL_LIBRARIES})
|
||||
endif()
|
|
@ -0,0 +1,256 @@
|
|||
#
|
||||
# Copyright 2013 Pixar
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
# with the following modification; you may not use this file except in
|
||||
# compliance with the Apache License and the following modification to it:
|
||||
# Section 6. Trademarks. is deleted and replaced with:
|
||||
#
|
||||
# 6. Trademarks. This License does not grant permission to use the trade
|
||||
# names, trademarks, service marks, or product names of the Licensor
|
||||
# and its affiliates, except as required to comply with Section 4(c) of
|
||||
# the License and to reproduce the content of the NOTICE file.
|
||||
#
|
||||
# You may obtain a copy of the Apache License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the Apache License with the above modification is
|
||||
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the Apache License for the specific
|
||||
# language governing permissions and limitations under the Apache License.
|
||||
#
|
||||
|
||||
# Try to find GLFW library and include path.
|
||||
# Once done this will define
|
||||
#
|
||||
# GLFW_FOUND
|
||||
# GLFW_INCLUDE_DIR
|
||||
# GLFW_LIBRARIES
|
||||
#
|
||||
|
||||
find_path( GLFW_INCLUDE_DIR
|
||||
NAMES
|
||||
GLFW/glfw3.h
|
||||
HINTS
|
||||
"${GLFW_LOCATION}/include"
|
||||
"$ENV{GLFW_LOCATION}/include"
|
||||
PATHS
|
||||
"$ENV{PROGRAMFILES}/GLFW/include"
|
||||
"${OPENGL_INCLUDE_DIR}"
|
||||
/usr/openwin/share/include
|
||||
/usr/openwin/include
|
||||
/usr/X11R6/include
|
||||
/usr/include/X11
|
||||
/opt/graphics/OpenGL/include
|
||||
/opt/graphics/OpenGL/contrib/libglfw
|
||||
/usr/local/include
|
||||
/usr/include/GL
|
||||
/usr/include
|
||||
DOC
|
||||
"The directory where GLFW/glfw3.h resides"
|
||||
)
|
||||
|
||||
#
|
||||
# XXX: Do we still need to search for GL/glfw.h?
|
||||
#
|
||||
find_path( GLFW_INCLUDE_DIR
|
||||
NAMES
|
||||
GL/glfw.h
|
||||
HINTS
|
||||
"${GLFW_LOCATION}/include"
|
||||
"$ENV{GLFW_LOCATION}/include"
|
||||
PATHS
|
||||
"$ENV{PROGRAMFILES}/GLFW/include"
|
||||
"${OPENGL_INCLUDE_DIR}"
|
||||
/usr/openwin/share/include
|
||||
/usr/openwin/include
|
||||
/usr/X11R6/include
|
||||
/usr/include/X11
|
||||
/opt/graphics/OpenGL/include
|
||||
/opt/graphics/OpenGL/contrib/libglfw
|
||||
/usr/local/include
|
||||
/usr/include/GL
|
||||
/usr/include
|
||||
DOC
|
||||
"The directory where GL/glfw.h resides"
|
||||
)
|
||||
|
||||
if (WIN32)
|
||||
if(CYGWIN)
|
||||
find_library( GLFW_glfw_LIBRARY
|
||||
NAMES
|
||||
glfw32
|
||||
HINTS
|
||||
"${GLFW_LOCATION}/lib"
|
||||
"${GLFW_LOCATION}/lib/x64"
|
||||
"$ENV{GLFW_LOCATION}/lib"
|
||||
PATHS
|
||||
"${OPENGL_LIBRARY_DIR}"
|
||||
/usr/lib
|
||||
/usr/lib/w32api
|
||||
/usr/local/lib
|
||||
/usr/X11R6/lib
|
||||
DOC
|
||||
"The GLFW library"
|
||||
)
|
||||
else()
|
||||
find_library( GLFW_glfw_LIBRARY
|
||||
NAMES
|
||||
glfw32
|
||||
glfw32s
|
||||
glfw
|
||||
glfw3
|
||||
HINTS
|
||||
"${GLFW_LOCATION}/lib"
|
||||
"${GLFW_LOCATION}/lib/x64"
|
||||
"${GLFW_LOCATION}/lib-msvc110"
|
||||
"${GLFW_LOCATION}/lib-vc2012"
|
||||
"$ENV{GLFW_LOCATION}/lib"
|
||||
"$ENV{GLFW_LOCATION}/lib/x64"
|
||||
"$ENV{GLFW_LOCATION}/lib-msvc110"
|
||||
"$ENV{GLFW_LOCATION}/lib-vc2012"
|
||||
PATHS
|
||||
"$ENV{PROGRAMFILES}/GLFW/lib"
|
||||
"${OPENGL_LIBRARY_DIR}"
|
||||
DOC
|
||||
"The GLFW library"
|
||||
)
|
||||
endif()
|
||||
else ()
|
||||
if (APPLE)
|
||||
find_library( GLFW_glfw_LIBRARY glfw
|
||||
NAMES
|
||||
glfw
|
||||
glfw3
|
||||
HINTS
|
||||
"${GLFW_LOCATION}/lib"
|
||||
"${GLFW_LOCATION}/lib/cocoa"
|
||||
"$ENV{GLFW_LOCATION}/lib"
|
||||
"$ENV{GLFW_LOCATION}/lib/cocoa"
|
||||
PATHS
|
||||
/usr/local/lib
|
||||
)
|
||||
set(GLFW_cocoa_LIBRARY "-framework Cocoa" CACHE STRING "Cocoa framework for OSX")
|
||||
set(GLFW_corevideo_LIBRARY "-framework CoreVideo" CACHE STRING "CoreVideo framework for OSX")
|
||||
set(GLFW_iokit_LIBRARY "-framework IOKit" CACHE STRING "IOKit framework for OSX")
|
||||
else ()
|
||||
# (*)NIX
|
||||
|
||||
find_package(Threads REQUIRED)
|
||||
|
||||
find_package(X11 REQUIRED)
|
||||
|
||||
if(NOT X11_Xrandr_FOUND)
|
||||
message(FATAL_ERROR "Xrandr library not found - required for GLFW")
|
||||
endif()
|
||||
|
||||
if(NOT X11_xf86vmode_FOUND)
|
||||
message(FATAL_ERROR "xf86vmode library not found - required for GLFW")
|
||||
endif()
|
||||
|
||||
if(NOT X11_Xcursor_FOUND)
|
||||
message(FATAL_ERROR "Xcursor library not found - required for GLFW")
|
||||
endif()
|
||||
|
||||
if(NOT X11_Xinerama_FOUND)
|
||||
message(FATAL_ERROR "Xinerama library not found - required for GLFW")
|
||||
endif()
|
||||
|
||||
list(APPEND GLFW_x11_LIBRARY "${X11_Xrandr_LIB}" "${X11_Xxf86vm_LIB}" "${X11_Xcursor_LIB}" "${X11_Xinerama_LIB}" "${CMAKE_THREAD_LIBS_INIT}" -lrt -lXi)
|
||||
|
||||
find_library( GLFW_glfw_LIBRARY
|
||||
NAMES
|
||||
glfw
|
||||
glfw3
|
||||
HINTS
|
||||
"${GLFW_LOCATION}/lib"
|
||||
"$ENV{GLFW_LOCATION}/lib"
|
||||
"${GLFW_LOCATION}/lib/x11"
|
||||
"$ENV{GLFW_LOCATION}/lib/x11"
|
||||
PATHS
|
||||
/usr/lib64
|
||||
/usr/lib
|
||||
/usr/lib/${CMAKE_LIBRARY_ARCHITECTURE}
|
||||
/usr/local/lib64
|
||||
/usr/local/lib
|
||||
/usr/local/lib/${CMAKE_LIBRARY_ARCHITECTURE}
|
||||
/usr/openwin/lib
|
||||
/usr/X11R6/lib
|
||||
DOC
|
||||
"The GLFW library"
|
||||
)
|
||||
endif (APPLE)
|
||||
endif (WIN32)
|
||||
|
||||
set( GLFW_FOUND "NO" )
|
||||
|
||||
if(GLFW_INCLUDE_DIR)
|
||||
|
||||
if(GLFW_glfw_LIBRARY)
|
||||
set( GLFW_LIBRARIES "${GLFW_glfw_LIBRARY}"
|
||||
"${GLFW_x11_LIBRARY}"
|
||||
"${GLFW_cocoa_LIBRARY}"
|
||||
"${GLFW_iokit_LIBRARY}"
|
||||
"${GLFW_corevideo_LIBRARY}" )
|
||||
set( GLFW_FOUND "YES" )
|
||||
set (GLFW_LIBRARY "${GLFW_LIBRARIES}")
|
||||
set (GLFW_INCLUDE_PATH "${GLFW_INCLUDE_DIR}")
|
||||
endif(GLFW_glfw_LIBRARY)
|
||||
|
||||
|
||||
# Tease the GLFW_VERSION numbers from the lib headers
|
||||
function(parseVersion FILENAME VARNAME)
|
||||
|
||||
set(PATTERN "^#define ${VARNAME}.*$")
|
||||
|
||||
file(STRINGS "${GLFW_INCLUDE_DIR}/${FILENAME}" TMP REGEX ${PATTERN})
|
||||
|
||||
string(REGEX MATCHALL "[0-9]+" TMP ${TMP})
|
||||
|
||||
set(${VARNAME} ${TMP} PARENT_SCOPE)
|
||||
|
||||
endfunction()
|
||||
|
||||
|
||||
if(EXISTS "${GLFW_INCLUDE_DIR}/GL/glfw.h")
|
||||
|
||||
parseVersion(GL/glfw.h GLFW_VERSION_MAJOR)
|
||||
parseVersion(GL/glfw.h GLFW_VERSION_MINOR)
|
||||
parseVersion(GL/glfw.h GLFW_VERSION_REVISION)
|
||||
|
||||
elseif(EXISTS "${GLFW_INCLUDE_DIR}/GLFW/glfw3.h")
|
||||
|
||||
parseVersion(GLFW/glfw3.h GLFW_VERSION_MAJOR)
|
||||
parseVersion(GLFW/glfw3.h GLFW_VERSION_MINOR)
|
||||
parseVersion(GLFW/glfw3.h GLFW_VERSION_REVISION)
|
||||
|
||||
endif()
|
||||
|
||||
if(${GLFW_VERSION_MAJOR} OR ${GLFW_VERSION_MINOR} OR ${GLFW_VERSION_REVISION})
|
||||
set(GLFW_VERSION "${GLFW_VERSION_MAJOR}.${GLFW_VERSION_MINOR}.${GLFW_VERSION_REVISION}")
|
||||
set(GLFW_VERSION_STRING "${GLFW_VERSION}")
|
||||
mark_as_advanced(GLFW_VERSION)
|
||||
endif()
|
||||
|
||||
endif(GLFW_INCLUDE_DIR)
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
|
||||
find_package_handle_standard_args(GLFW
|
||||
REQUIRED_VARS
|
||||
GLFW_INCLUDE_DIR
|
||||
GLFW_LIBRARIES
|
||||
VERSION_VAR
|
||||
GLFW_VERSION
|
||||
)
|
||||
|
||||
mark_as_advanced(
|
||||
GLFW_INCLUDE_DIR
|
||||
GLFW_LIBRARIES
|
||||
GLFW_glfw_LIBRARY
|
||||
GLFW_cocoa_LIBRARY
|
||||
)
|
||||
|
||||
|
|
@ -0,0 +1,63 @@
|
|||
# Locate LuaJIT library
|
||||
# This module defines
|
||||
# LUAJIT_FOUND, if false, do not try to link to Lua
|
||||
# LUA_LIBRARIES
|
||||
# LUA_INCLUDE_DIR, where to find lua.h
|
||||
# LUAJIT_VERSION_STRING, the version of Lua found (since CMake 2.8.8)
|
||||
|
||||
## Copied from default CMake FindLua51.cmake
|
||||
|
||||
find_path(LUA_INCLUDE_DIR luajit.h
|
||||
HINTS
|
||||
ENV LUA_DIR
|
||||
PATH_SUFFIXES include/luajit-2.0 include
|
||||
PATHS
|
||||
~/Library/Frameworks
|
||||
/Library/Frameworks
|
||||
/sw # Fink
|
||||
/opt/local # DarwinPorts
|
||||
/opt/csw # Blastwave
|
||||
/opt
|
||||
)
|
||||
|
||||
find_library(LUA_LIBRARY
|
||||
NAMES luajit-5.1
|
||||
HINTS
|
||||
ENV LUA_DIR
|
||||
PATH_SUFFIXES lib
|
||||
PATHS
|
||||
~/Library/Frameworks
|
||||
/Library/Frameworks
|
||||
/sw
|
||||
/opt/local
|
||||
/opt/csw
|
||||
/opt
|
||||
)
|
||||
|
||||
if(LUA_LIBRARY)
|
||||
# include the math library for Unix
|
||||
if(UNIX AND NOT APPLE)
|
||||
find_library(LUA_MATH_LIBRARY m)
|
||||
set( LUA_LIBRARIES "${LUA_LIBRARY};${LUA_MATH_LIBRARY}" CACHE STRING "Lua Libraries")
|
||||
# For Windows and Mac, don't need to explicitly include the math library
|
||||
else()
|
||||
set( LUA_LIBRARIES "${LUA_LIBRARY}" CACHE STRING "Lua Libraries")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(LUA_INCLUDE_DIR AND EXISTS "${LUA_INCLUDE_DIR}/luajit.h")
|
||||
file(STRINGS "${LUA_INCLUDE_DIR}/luajit.h" luajit_version_str REGEX "^#define[ \t]+LUAJIT_VERSION[ \t]+\"LuaJIT .+\"")
|
||||
|
||||
string(REGEX REPLACE "^#define[ \t]+LUAJIT_VERSION[ \t]+\"LuaJIT ([^\"]+)\".*" "\\1" LUAJIT_VERSION_STRING "${luajit_version_str}")
|
||||
unset(luajit_version_str)
|
||||
endif()
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
# handle the QUIETLY and REQUIRED arguments and set LUA_FOUND to TRUE if
|
||||
# all listed variables are TRUE
|
||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(LuaJIT
|
||||
REQUIRED_VARS LUA_LIBRARIES LUA_INCLUDE_DIR
|
||||
VERSION_VAR LUAJIT_VERSION_STRING)
|
||||
|
||||
mark_as_advanced(LUA_INCLUDE_DIR LUA_LIBRARIES LUA_LIBRARY LUA_MATH_LIBRARY)
|
||||
|
|
@ -0,0 +1,81 @@
|
|||
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
set(ASSIMP_ARCHITECTURE "64")
|
||||
elseif(CMAKE_SIZEOF_VOID_P EQUAL 4)
|
||||
set(ASSIMP_ARCHITECTURE "32")
|
||||
endif(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
|
||||
if(WIN32)
|
||||
set(ASSIMP_ROOT_DIR CACHE PATH "ASSIMP root directory")
|
||||
|
||||
# Find path of each library
|
||||
find_path(ASSIMP_INCLUDE_DIR
|
||||
NAMES
|
||||
assimp/anim.h
|
||||
HINTS
|
||||
${ASSIMP_ROOT_DIR}/include
|
||||
)
|
||||
|
||||
if(MSVC12)
|
||||
set(ASSIMP_MSVC_VERSION "vc120")
|
||||
elseif(MSVC14)
|
||||
set(ASSIMP_MSVC_VERSION "vc140")
|
||||
endif(MSVC12)
|
||||
|
||||
if(MSVC12 OR MSVC14)
|
||||
|
||||
find_path(ASSIMP_LIBRARY_DIR
|
||||
NAMES
|
||||
assimp-${ASSIMP_MSVC_VERSION}-mt.lib
|
||||
HINTS
|
||||
${ASSIMP_ROOT_DIR}/lib${ASSIMP_ARCHITECTURE}
|
||||
)
|
||||
|
||||
find_library(ASSIMP_LIBRARY_RELEASE assimp-${ASSIMP_MSVC_VERSION}-mt.lib PATHS ${ASSIMP_LIBRARY_DIR})
|
||||
find_library(ASSIMP_LIBRARY_DEBUG assimp-${ASSIMP_MSVC_VERSION}-mtd.lib PATHS ${ASSIMP_LIBRARY_DIR})
|
||||
|
||||
set(ASSIMP_LIBRARY
|
||||
optimized ${ASSIMP_LIBRARY_RELEASE}
|
||||
debug ${ASSIMP_LIBRARY_DEBUG}
|
||||
)
|
||||
|
||||
set(ASSIMP_LIBRARIES "ASSIMP_LIBRARY_RELEASE" "ASSIMP_LIBRARY_DEBUG")
|
||||
|
||||
FUNCTION(ASSIMP_COPY_BINARIES TargetDirectory)
|
||||
ADD_CUSTOM_TARGET(AssimpCopyBinaries
|
||||
COMMAND ${CMAKE_COMMAND} -E copy ${ASSIMP_ROOT_DIR}/bin${ASSIMP_ARCHITECTURE}/assimp-${ASSIMP_MSVC_VERSION}-mtd.dll ${TargetDirectory}/Debug/assimp-${ASSIMP_MSVC_VERSION}-mtd.dll
|
||||
COMMAND ${CMAKE_COMMAND} -E copy ${ASSIMP_ROOT_DIR}/bin${ASSIMP_ARCHITECTURE}/assimp-${ASSIMP_MSVC_VERSION}-mt.dll ${TargetDirectory}/Release/assimp-${ASSIMP_MSVC_VERSION}-mt.dll
|
||||
COMMENT "Copying Assimp binaries to '${TargetDirectory}'"
|
||||
VERBATIM)
|
||||
ENDFUNCTION(ASSIMP_COPY_BINARIES)
|
||||
|
||||
endif()
|
||||
|
||||
else(WIN32)
|
||||
|
||||
find_path(
|
||||
assimp_INCLUDE_DIRS
|
||||
NAMES postprocess.h scene.h version.h config.h cimport.h
|
||||
PATHS /usr/local/include/assimp
|
||||
)
|
||||
|
||||
find_library(
|
||||
assimp_LIBRARIES
|
||||
NAMES assimp
|
||||
PATHS /usr/local/lib/
|
||||
)
|
||||
|
||||
if (assimp_INCLUDE_DIRS AND assimp_LIBRARIES)
|
||||
SET(assimp_FOUND TRUE)
|
||||
ENDIF (assimp_INCLUDE_DIRS AND assimp_LIBRARIES)
|
||||
|
||||
if (assimp_FOUND)
|
||||
if (NOT assimp_FIND_QUIETLY)
|
||||
message(STATUS "Found asset importer library: ${assimp_LIBRARIES}")
|
||||
endif (NOT assimp_FIND_QUIETLY)
|
||||
else (assimp_FOUND)
|
||||
if (assimp_FIND_REQUIRED)
|
||||
message(FATAL_ERROR "Could not find asset importer library")
|
||||
endif (assimp_FIND_REQUIRED)
|
||||
endif (assimp_FOUND)
|
||||
|
||||
endif(WIN32)
|
Loading…
Reference in New Issue