Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve cmake (round 2!) #45

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,12 @@
[submodule "dependencies/tlsf"]
path = dependencies/tlsf
url = https://github.com/mattconte/tlsf
[submodule "dependencies/SDL2"]
path = dependencies/SDL2
url = https://github.com/spurious/SDL-mirror.git
[submodule "dependencies/googletest"]
path = dependencies/googletest
url = https://github.com/google/googletest.git
[submodule "dependencies/luajit"]
path = dependencies/luajit
url = https://github.com/LuaDist/luajit.git
35 changes: 30 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 3.2)

# Setup modules
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
include(cotire)

project(Intrinsic)
Expand Down Expand Up @@ -77,11 +77,11 @@ if (NOT INTR_FINAL_BUILD)
set(PhysX_PROFILE ON)
endif()

find_package(GoogleTest REQUIRED)
find_package(GLSLang REQUIRED)
find_package(LuaJIT REQUIRED)
find_package(PhysX REQUIRED Common Cooking CharacterKinematic Extensions PxFoundation)

find_package(SDL2 REQUIRED)
find_package(SDL2 REQUIRED QUIET) # SDL2 is pretty noisy. most people won't care.
find_package(Vulkan REQUIRED)

if(INTR_BUILD_INTRINSICED)
Expand Down Expand Up @@ -164,8 +164,13 @@ if (INTR_BUILD_STANDALONE_APP)
endif()

# Libs
add_library(IntrinsicCore ${INTR_CORE_SOURCE_FILES} ${INTR_CORE_C_SOURCE_FILES}
${INTDEP_SOURCE_FILES} ${INTR_CORE_HEADER_FILES} ${INTR_CORE_DEP_SOURCE_FILES})
add_library(IntrinsicCore
${INTR_CORE_SOURCE_FILES}
${INTR_CORE_C_SOURCE_FILES}
${INTDEP_SOURCE_FILES}
${INTR_CORE_HEADER_FILES}
${INTR_CORE_DEP_SOURCE_FILES}
)

if (INTR_BUILD_INTRINSICED)
add_library(IntrinsicAssetManagement ${INTASSET_SOURCE_FILES} ${INTASSET_HEADER_FILES})
Expand Down Expand Up @@ -281,3 +286,23 @@ if(MSVC)
set_target_properties(Intrinsic PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY ../app)
set_target_properties(IntrinsicEd PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY ../app)
endif()

## Installation Rules
install(
FILES ${INTR_CORE_HEADER_FILES}
DESTINATION include
)

install(
TARGETS IntrinsicCore LIBRARY
ARCHIVE DESTINATION lib
)

install(
DIRECTORY app
DESTINATION bin
)
install(
TARGETS Intrinsic
RUNTIME DESTINATION bin/app
)
2 changes: 1 addition & 1 deletion IntrinsicCore/src/IntrinsicCoreRenderingIBL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ _INTR_INLINE void _preFilterGGXOpt(const gli::texture_cube& p_Input,

const float saSample = 1.0f / (float(sampleCount) * pdf + 0.0001f);
const float mipLevel =
glm::clamp(1.0f /* Bias*/ + 0.5f * log2(saSample / saTexel), 0.0f,
glm::clamp(1.0f /* Bias*/ + 0.5f * static_cast<float>(log2(saSample / saTexel)), 0.0f,
(float)p_Input.max_level());

preFilteredColor += glm::vec3(sourceSamplerTrilinear.texture_lod(
Expand Down
3 changes: 3 additions & 0 deletions IntrinsicCore/src/stdafx.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
#include "tinydir/tinydir.h"

// SDL
#include "SDL_config.h"
#undef HAVE_LIBUDEV_H
#include "SDL.h"
#include "SDL_syswm.h"
#undef Bool
Expand Down Expand Up @@ -73,6 +75,7 @@
#include <cmath>
#include <thread>
#include <mutex>
#include "stdafx_stl.h"

// Core related includes
#include "IntrinsicCoreVersion.h"
Expand Down
14 changes: 14 additions & 0 deletions IntrinsicCore/src/stdafx_stl.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#pragma once

namespace std
{

template<class E>class hash {
using sfinae = typename std::enable_if<std::is_enum<E>::value, E>::type;
public:
size_t operator()(const E&e) const {
return std::hash<typename std::underlying_type<E>::type>()(e);
}
};

}//::std::
148 changes: 57 additions & 91 deletions cmake/FindGLSLang.cmake
Original file line number Diff line number Diff line change
@@ -1,100 +1,66 @@
# Locate the GLSLang library

FIND_PATH(GLSLang_ROOT_DIR glslang/Include/Common.h
FIND_PATH(GLSLang_ROOT_DIR glslang/CMakeLists.txt
PATHS
${CMAKE_SOURCE_DIR}/dependencies/glslang
${CMAKE_CURRENT_SOURCE_DIR}/dependencies/glslang
)

FIND_LIBRARY(GLSLang_LIBRARY_DEBUG glslangd glslang
PATH_SUFFIXES lib64 lib Debug
PATHS
${CMAKE_SOURCE_DIR}/dependencies/glslang/build/glslang
${CMAKE_SOURCE_DIR}/dependencies/glslang/build_debug/install
)

FIND_LIBRARY(GLSLang_LIBRARY_RELEASE glslang
PATH_SUFFIXES lib64 lib Release
PATHS
${CMAKE_SOURCE_DIR}/dependencies/glslang/build/glslang
${CMAKE_SOURCE_DIR}/dependencies/glslang/build/install
)

FIND_LIBRARY(GLSLang_LIBRARY_HLSL_DEBUG HLSLd HLSL
PATH_SUFFIXES lib64 lib Debug
PATHS
${CMAKE_SOURCE_DIR}/dependencies/glslang/build/hlsl
${CMAKE_SOURCE_DIR}/dependencies/glslang/build_debug/install
)

FIND_LIBRARY(GLSLang_LIBRARY_HLSL_RELEASE HLSL
PATH_SUFFIXES lib64 lib Release
PATHS
${CMAKE_SOURCE_DIR}/dependencies/glslang/build/hlsl
${CMAKE_SOURCE_DIR}/dependencies/glslang/build/install
)

FIND_LIBRARY(GLSLang_LIBRARY_OGL_DEBUG OGLCompilerd OGLCompiler
PATH_SUFFIXES lib64 lib Debug
PATHS
${CMAKE_SOURCE_DIR}/dependencies/glslang/build/OGLCompilersDLL
${CMAKE_SOURCE_DIR}/dependencies/glslang/build_debug/install
)

FIND_LIBRARY(GLSLang_LIBRARY_OGL_RELEASE OGLCompiler
PATH_SUFFIXES lib64 lib Release
PATHS
${CMAKE_SOURCE_DIR}/dependencies/glslang/build/OGLCompilersDLL
${CMAKE_SOURCE_DIR}/dependencies/glslang/build/install
)
IF(NOT GLSLang_ROOT_DIR)
MESSAGE(FATAL_ERROR "cannot find glslang package; forgot submodule update --init?")
ELSE()
ADD_SUBDIRECTORY(${GLSLang_ROOT_DIR})

FIND_LIBRARY(GLSLang_LIBRARY_OSDEP_DEBUG OSDependentd OSDependent
PATH_SUFFIXES lib64 lib Debug
PATHS
${CMAKE_SOURCE_DIR}/dependencies/glslang/build/glslang/OSDependent/Windows
${CMAKE_SOURCE_DIR}/dependencies/glslang/build_debug/glslang/OSDependent/Unix
)
SET(GLSLang_LIBRARY_DEBUG glslangd)
SET(GLSLang_LIBRARY_RELEASE glslang)
SET(GLSLang_LIBRARY_HLSL_DEBUG HLSLd)
SET(GLSLang_LIBRARY_HLSL_RELEASE HLSL)
SET(GLSLang_LIBRARY_OGL_DEBUG OGLCompilerd)
SET(GLSLang_LIBRARY_OGL_RELEASE OGLCompiler)
SET(GLSLang_LIBRARY_OSDEP_DEBUG OSDependentd)
SET(GLSLang_LIBRARY_OSDEP_RELEASE OSDependent)
SET(GLSLang_LIBRARY_SPIRV_DEBUG SPIRVd)
SET(GLSLang_LIBRARY_SPIRV_RELEASE SPIRV)

FIND_LIBRARY(GLSLang_LIBRARY_OSDEP_RELEASE OSDependent
PATH_SUFFIXES lib64 lib Release
PATHS
${CMAKE_SOURCE_DIR}/dependencies/glslang/build/glslang/OSDependent/Windows
${CMAKE_SOURCE_DIR}/dependencies/glslang/build/glslang/OSDependent/Unix
)
SET(GLSLang_LIBRARIES
debug ${GLSLang_LIBRARY_DEBUG}
debug ${GLSLang_LIBRARY_HLSL_DEBUG}
debug ${GLSLang_LIBRARY_OGL_DEBUG}
debug ${GLSLang_LIBRARY_OSDEP_DEBUG}
debug ${GLSLang_LIBRARY_SPIRV_DEBUG}
optimized ${GLSLang_LIBRARY_RELEASE}
optimized ${GLSLang_LIBRARY_HLSL_RELEASE}
optimized ${GLSLang_LIBRARY_OGL_RELEASE}
optimized ${GLSLang_LIBRARY_OSDEP_RELEASE}
optimized ${GLSLang_LIBRARY_SPIRV_RELEASE}
)

FIND_LIBRARY(GLSLang_LIBRARY_SPIRV_DEBUG SPIRVd SPIRV
PATH_SUFFIXES lib64 lib Debug
PATHS
${CMAKE_SOURCE_DIR}/dependencies/glslang/build/SPIRV
${CMAKE_SOURCE_DIR}/dependencies/glslang/build_debug/install
)
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(GLSLang DEFAULT_MSG
GLSLang_ROOT_DIR
GLSLang_LIBRARY_DEBUG
GLSLang_LIBRARY_HLSL_DEBUG
GLSLang_LIBRARY_OGL_DEBUG
GLSLang_LIBRARY_OSDEP_DEBUG
GLSLang_LIBRARY_SPIRV_DEBUG
GLSLang_LIBRARY_RELEASE
GLSLang_LIBRARY_HLSL_RELEASE
GLSLang_LIBRARY_OGL_RELEASE
GLSLang_LIBRARY_OSDEP_RELEASE
GLSLang_LIBRARY_SPIRV_RELEASE
)

FIND_LIBRARY(GLSLang_LIBRARY_SPIRV_RELEASE SPIRV
PATH_SUFFIXES lib64 lib Release
PATHS
${CMAKE_SOURCE_DIR}/dependencies/glslang/build/SPIRV
${CMAKE_SOURCE_DIR}/dependencies/glslang/build/install
)

SET(GLSLang_LIBRARIES
debug ${GLSLang_LIBRARY_DEBUG}
debug ${GLSLang_LIBRARY_HLSL_DEBUG}
debug ${GLSLang_LIBRARY_OGL_DEBUG}
debug ${GLSLang_LIBRARY_OSDEP_DEBUG}
debug ${GLSLang_LIBRARY_SPIRV_DEBUG}
optimized ${GLSLang_LIBRARY_RELEASE}
optimized ${GLSLang_LIBRARY_HLSL_RELEASE}
optimized ${GLSLang_LIBRARY_OGL_RELEASE}
optimized ${GLSLang_LIBRARY_OSDEP_RELEASE}
optimized ${GLSLang_LIBRARY_SPIRV_RELEASE}
)

INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(GLSLang DEFAULT_MSG GLSLang_ROOT_DIR GLSLang_LIBRARY_DEBUG GLSLang_LIBRARY_RELEASE
GLSLang_LIBRARY_HLSL_DEBUG GLSLang_LIBRARY_OGL_DEBUG GLSLang_LIBRARY_OSDEP_DEBUG GLSLang_LIBRARY_SPIRV_DEBUG
GLSLang_LIBRARY_HLSL_RELEASE GLSLang_LIBRARY_OGL_RELEASE GLSLang_LIBRARY_OSDEP_RELEASE GLSLang_LIBRARY_SPIRV_RELEASE)

MARK_AS_ADVANCED(GLSLang_ROOT_DIR GLSLang_LIBRARIES
GLSLang_LIBRARY_DEBUG GLSLang_LIBRARY_RELEASE
GLSLang_LIBRARY_HLSL_DEBUG GLSLang_LIBRARY_OGL_DEBUG GLSLang_LIBRARY_OSDEP_DEBUG GLSLang_LIBRARY_SPIRV_DEBUG
GLSLang_LIBRARY_HLSL_RELEASE GLSLang_LIBRARY_OGL_RELEASE GLSLang_LIBRARY_OSDEP_RELEASE GLSLang_LIBRARY_SPIRV_RELEASE
)
MARK_AS_ADVANCED(
GLSLang_ROOT_DIR
GLSLang_LIBRARIES
GLSLang_LIBRARY_DEBUG
GLSLang_LIBRARY_RELEASE
GLSLang_LIBRARY_HLSL_DEBUG
GLSLang_LIBRARY_OGL_DEBUG
GLSLang_LIBRARY_OSDEP_DEBUG
GLSLang_LIBRARY_SPIRV_DEBUG
GLSLang_LIBRARY_HLSL_RELEASE
GLSLang_LIBRARY_OGL_RELEASE
GLSLang_LIBRARY_OSDEP_RELEASE
GLSLang_LIBRARY_SPIRV_RELEASE
)
ENDIF()
13 changes: 13 additions & 0 deletions cmake/FindGoogleTest.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Locate the GLSLang library

FIND_PATH(GOOGLETEST_ROOT_DIR googletest/include/gtest/gtest.h
PATHS
${CMAKE_CURRENT_SOURCE_DIR}/dependencies/googletest
)

IF(NOT GOOGLETEST_ROOT_DIR)
MESSAGE(FATAL_ERROR "cannot find googletest package; forgot submodule update --init?")
ELSE()
ADD_SUBDIRECTORY(${GOOGLETEST_ROOT_DIR})
INCLUDE(FindPackageHandleStandardArgs)
ENDIF()
84 changes: 25 additions & 59 deletions cmake/FindLuaJIT.cmake
Original file line number Diff line number Diff line change
@@ -1,63 +1,29 @@
# Locate Lua library
# This module defines
# LuaJIT_FOUND, if false, do not try to link to Lua
# LuaJIT_LIBRARIES
# LuaJIT_INCLUDE_DIR, where to find lua.h
#
# Note that the expected include convention is
# #include "lua.h"
# and not
# #include <lua/lua.h>
# This is because, the lua location is not standardized and may exist
# in locations other than lua/

#=============================================================================
# Copyright 2007-2009 Kitware, Inc.
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
# (To distributed this file outside of CMake, substitute the full
# License text for the above reference.)
#
# ################
# 2010 - modified for cronkite to find luajit instead of lua, as it was before.
# 2015 - modified to help Intrinsic find LuaJIT
#

FIND_PATH(LuaJIT_INCLUDE_DIR lua.h
HINTS
$ENV{LuaJIT_DIR}
PATH_SUFFIXES include/luajit-2.0 include/luajit2.0 include/luajit include
PATHS
${CMAKE_SOURCE_DIR}/dependencies/lua
)

FIND_LIBRARY(LuaJIT_LIBRARY
NAMES luajit-51 luajit-5.1 luajit51 luajit lua-51 lua-5.1 lua51 lua
HINTS
$ENV{LuaJIT_DIR}
PATH_SUFFIXES lib64 lib

FIND_PATH(LuaJIT_ROOT_DIR src/lua.h
PATHS
${CMAKE_SOURCE_DIR}/dependencies/lua
${CMAKE_CURRENT_SOURCE_DIR}/dependencies/luajit
)

IF(LuaJIT_LIBRARY)
# include the math library for Unix
IF(UNIX AND NOT APPLE)
FIND_LIBRARY(LuaJIT_MATH_LIBRARY m)
SET( LuaJIT_LIBRARIES "${LuaJIT_LIBRARY};${LuaJIT_MATH_LIBRARY}" CACHE STRING "Lua Libraries")
# For Windows and Mac, don't need to explicitly include the math library
ELSE(UNIX AND NOT APPLE)
SET( LuaJIT_LIBRARIES "${LuaJIT_LIBRARY}" CACHE STRING "Lua Libraries")
ENDIF(UNIX AND NOT APPLE)
ENDIF(LuaJIT_LIBRARY)

INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(LuaJIT DEFAULT_MSG LuaJIT_LIBRARIES LuaJIT_INCLUDE_DIR)

MARK_AS_ADVANCED(LuaJIT_INCLUDE_DIR LuaJIT_LIBRARIES LuaJIT_LIBRARY LuaJIT_MATH_LIBRARY)
IF(NOT LuaJIT_ROOT_DIR)
MESSAGE(FATAL_ERROR "cannot find luajit package; forgot submodule update --init?")
ELSE()
ADD_SUBDIRECTORY(${LuaJIT_ROOT_DIR})

SET(LuaJIT_INCLUDE_DIR
${CMAKE_CURRENT_BINARY_DIR}/dependencies/luajit ##for luaconf.h
${LuaJIT_ROOT_DIR}/src
)

LIST(APPEND LuaJIT_LIBRARIES
liblua
)

INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(LuaJIT DEFAULT_MSG LuaJIT_LIBRARIES LuaJIT_INCLUDE_DIR)

MARK_AS_ADVANCED(
LuaJIT_INCLUDE_DIR
)

ENDIF()
Loading