Skip to content

Commit

Permalink
# simplified build process (WIP)
Browse files Browse the repository at this point in the history
  • Loading branch information
Thanduriel committed Jul 5, 2020
1 parent 2c597fe commit d49773b
Show file tree
Hide file tree
Showing 30 changed files with 2,850 additions and 58 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
/x64
/win32
/lib
/build
/dependencies/SDL

*.suo
Expand Down
11 changes: 6 additions & 5 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,17 @@
path = dependencies/glew
url = git@github.com:Perlmint/glew-cmake.git
[submodule "dependencies/assimp"]

path = tools/meshprocessor/dependencies/assimp

url = https://github.com/assimp/assimp
[submodule "dependencies/glew-cmake"]
path = dependencies/glew-cmake
url = https://github.com/Perlmint/glew-cmake.git
[submodule "tools/meshprocessor/dependencies/quickhull"]
path = tools/meshprocessor/dependencies/quickhull
url = git@github.com:akuukka/quickhull.git
[submodule "dependencies/clunk"]
path = dependencies/clunk
url = git@github.com:whoozle/clunk.git
[submodule "dependencies/JoFileLib/dependencies/libpng"]
path = dependencies/JoFileLib/dependencies/libpng
url = https://github.com/glennrp/libpng.git
[submodule "dependencies/JoFileLib/dependencies/zlib"]
path = dependencies/JoFileLib/dependencies/zlib
url = https://github.com/madler/zlib.git
53 changes: 29 additions & 24 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
cmake_minimum_required (VERSION 3.1)
cmake_minimum_required (VERSION 3.8)
project (wimp_s)

# require c++17 since it is finished
set (CMAKE_CXX_STANDARD 17)
set (CMAKE_CXX_STANDARD_REQUIRED ON)

Expand All @@ -27,60 +26,66 @@ endmacro()
# execute tha macro
GroupSources(src)

# needs to be known to link with the libraries
add_executable(wimp_s ${SOURCE_FILES})

# faster compilation with multithreading
# cmake does not support vs compiler switches for std
if(MSVC)
add_compile_options( /MP )
add_compile_options( /std:c++17 )

set(OPTIMIZATION_OPTIONS
$<$<CONFIG:Debug>:>
$<$<CONFIG:RelWithDebInfo>:>
$<$<CONFIG:Release>: /O2 /Ob2 /Oi /Ot /GL >
$<$<CONFIG:MinSizeRel>:>
$<$<CONFIG:Debug>:>
$<$<CONFIG:RelWithDebInfo>:>
$<$<CONFIG:Release>: /O2 /Ob2 /Oi /Ot /GL >
$<$<CONFIG:MinSizeRel>:>
)

add_compile_options( "${OPTIMIZATION_OPTIONS}" )
set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT wimp_s)
endif(MSVC)

# needs to be known to link with the libraries
add_executable(wimp_s ${SOURCE_FILES})
# navigation should always start from root
include_directories("src")

# glfw
set(GLFW_BUILD_DOCS OFF CACHE BOOL "" FORCE)
set(GLFW_BUILD_TESTS OFF CACHE BOOL "" FORCE)
set(GLFW_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
set(BUILD_SHARED_LIBS OFF CACHE BOOL "" FORCE)

add_subdirectory ("dependencies/glfw")
include_directories("dependencies/glfw/include")
target_link_libraries (wimp_s glfw)
target_link_libraries (wimp_s PUBLIC glfw)

# glew
set(glew-cmake_BUILD_SHARED OFF CACHE BOOL "" FORCE)
set(glew-cmake_BUILD_MULTI_CONTEXT OFF CACHE BOOL "" FORCE)
set(ONLY_LIBS ON CACHE BOOL "" FORCE)
add_subdirectory ("dependencies/glew/build/cmake")
include_directories("dependencies/glew/include")
target_link_libraries (wimp_s glew_s) # use static version
target_link_libraries (wimp_s PUBLIC glew_s) # use static version

# OpenGL
find_package(OpenGL REQUIRED)
target_link_libraries(wimp_s ${OPENGL_gl_LIBRARY})
target_link_libraries(wimp_s PUBLIC ${OPENGL_gl_LIBRARY})

# epsilon
include_directories("dependencies/epsilon/include")
file(GLOB SOURCE_FILES_EPSILON "dependencies/epsilon/src/*.cpp")
add_library(epsilon STATIC ${SOURCE_FILES_EPSILON})
target_link_libraries (wimp_s epsilon)
target_link_libraries (wimp_s PUBLIC epsilon)

# sound engine
#give hint where to find sdl from inside dependencies/clunk
set(CMAKE_INCLUDE_PATH "../sdl/include")
set(CMAKE_FRAMEWORK_PATH "../sdl")
find_package(SDL2 QUIET)
if(NOT SDL2_FOUND)
set(SDL2_DIR "${CMAKE_CURRENT_SOURCE_DIR}/dependencies/SDL")
endif(NOT SDL2_FOUND)
include_directories("dependencies/sdl/include")
add_subdirectory("dependencies/clunk")
include_directories("dependencies/clunk")
target_link_libraries (wimp_s clunk)
target_link_libraries (wimp_s PUBLIC clunk)

# You can define two import-locations: one for debug and one for release.
#set_target_properties( jofilelib PROPERTIES IMPORTED_LOCATION dependencies/jofilelib/debug )
include_directories("dependencies/jofilelib/include")
target_link_libraries (wimp_s
debug dependencies/JoFileLib/lib/Debug/jofile
optimized dependencies/JoFileLib/lib/Release/jofile)
# JoFileLib
add_subdirectory("dependencies/JoFileLib")
#target_include_directories(wimp_s PRIVATE "dependencies/JoFileLib/include")
target_link_libraries (wimp_s PRIVATE jofile)
51 changes: 51 additions & 0 deletions dependencies/JoFileLib/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
cmake_minimum_required(VERSION 2.6)

# Project Name
project(JoFileLib)

# Configuration
option(BUILD_SHARED "link shared libraries only" OFF)
if(MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /DNOMINMAX /D_CRT_SECURE_NO_WARNINGS /DWINAPI_FAMILY=WINAPI_FAMILY_DESKTOP_APP")
endif()

# Files
file(GLOB JoFileLib_SRC "${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp")
file(GLOB libpng_SRC "${CMAKE_CURRENT_SOURCE_DIR}/dependencies/libpng/*.c")
list(APPEND JoFileLib_SRC ${JoMemoryLib_SRC} ${libpng_SRC})
file(GLOB zlib_SRC "${CMAKE_CURRENT_SOURCE_DIR}/dependencies/zlib/*.c")
list(APPEND JoFileLib_SRC ${JoMemoryLib_SRC} ${zlib_SRC})

file(GLOB JoFileLib_INCLUDE "${CMAKE_CURRENT_SOURCE_DIR}/include/*.hpp")
file(GLOB_RECURSE deps_INCLUDE "${CMAKE_CURRENT_SOURCE_DIR}/dependencies/*.h")
#file(GLOB JoMemoryLib_INCLUDE "${CMAKE_CURRENT_SOURCE_DIR}/../JoMemory/include/*.hpp")
list(APPEND JoFileLib_INCLUDE ${JoMemoryLib_INCLUDE})

# Create Libraries
if(BUILD_SHARED)
add_library(jofile SHARED ${JoFileLib_SRC})
else()
add_library(jofile STATIC ${JoFileLib_SRC})
endif()

target_include_directories(jofile PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include")
target_include_directories(jofile PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/dependencies/zlib")
target_include_directories(jofile PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/dependencies/libpng")


# Installation
install(FILES ${JoFileLib_INCLUDE} DESTINATION include)

if(CMAKE_CONFIGURATION_TYPES) # multi-configuration generator
foreach(CONFIG_TYPE ${CMAKE_CONFIGURATION_TYPES})
install(TARGETS jofile
LIBRARY DESTINATION "lib/${CONFIG_TYPE}" CONFIGURATIONS ${CONFIG_TYPE}
ARCHIVE DESTINATION "lib/${CONFIG_TYPE}" CONFIGURATIONS ${CONFIG_TYPE}
)
endforeach()
else() # single-configuration generator
install(TARGETS jofile
LIBRARY DESTINATION "lib/${CMAKE_BUILD_TYPE}"
ARCHIVE DESTINATION "lib/${CMAKE_BUILD_TYPE}"
)
endif()
1 change: 1 addition & 0 deletions dependencies/JoFileLib/dependencies/libpng
Submodule libpng added at dbe3e0
1 change: 1 addition & 0 deletions dependencies/JoFileLib/dependencies/zlib
Submodule zlib added at cacf7f
36 changes: 18 additions & 18 deletions dependencies/JoFileLib/include/hybridarray.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ namespace Jo {
/// \param [in] _capacity Minimum capacity which should be allocated.
/// The allocated capacity must be ´max(_capacity, n)´. So there is
/// never less than the already existing internal memory block.
HybridArray(uint32 _capacity);
HybridArray(uint32_t _capacity);

/// \brief Copy construction (deep).
HybridArray(const HybridArray<T,N>& _other);
Expand All @@ -50,9 +50,9 @@ namespace Jo {
HybridArray<ElemType,N>& operator = (const HybridArray<T,N>& _other);

/// \brief Write-array access.
T& operator [] (uint32 _index);
T& operator [] (uint32_t _index);
/// \brief Read-array access.
const T& operator [] (uint32 _index) const;
const T& operator [] (uint32_t _index) const;

/// \brief Enlarge or prune the memory.
/// \param [in] _capacity New capacity/size. If _capacity is below n
Expand All @@ -62,7 +62,7 @@ namespace Jo {
///
/// The size changes if _capacity is below the current size and
/// unequal 0 (prune). The omitted elements are deleted.
void Resize(uint32 _capacity = 0);
void Resize(uint32_t _capacity = 0);

/// \brief Insert an element copy at the end of the array.
/// \details This might cause a resize with costs O(n).
Expand All @@ -77,11 +77,11 @@ namespace Jo {

/// \brief Insert an element copy at the given index of the array.
/// \details This might cause a resize with costs O(n).
const ElemType& Insert(uint32 _where, const ElemType& _element);
const ElemType& Insert(uint32_t _where, const ElemType& _element);

/// \brief Insert an element at the given index of the array.
/// \details This might cause a resize with costs O(n).
ElemType& Insert(uint32 _where, ElemType&& _element);
ElemType& Insert(uint32_t _where, ElemType&& _element);

/// \brief Delete an element in O(1). This operation changes the
/// element order by replacing the deleted with the last element.
Expand All @@ -94,8 +94,8 @@ namespace Jo {
/// \brief Delete all elements.
void Clear();

uint32 Size() const { return m_size; }
uint32 Capacity() const { return m_capacity; }
uint32_t Size() const { return m_size; }
uint32_t Capacity() const { return m_capacity; }

/// \brief Access first element
ElemType& First() { assert(m_size>0); return *m_data; }
Expand All @@ -105,11 +105,11 @@ namespace Jo {
ElemType& Last() { assert(m_size>0); return m_data[m_size-1]; }
const ElemType& Last() const { assert(m_size>0); return m_data[m_size-1]; }
protected:
uint32 m_capacity; ///< Maximum number of elements
uint32 m_size; ///< Current number of elements
uint32_t m_capacity; ///< Maximum number of elements
uint32_t m_size; ///< Current number of elements
ElemType* m_data; ///< Pointer to array memory block. Might be on stack or heap.

uint8 m_localStorage[sizeof(ElemType)*N]; ///< The local storage on stack or in object heap space.
uint8_t m_localStorage[sizeof(ElemType)*N]; ///< The local storage on stack or in object heap space.
};


Expand All @@ -131,7 +131,7 @@ namespace Jo {

// ********************************************************************* //
template<typename T, unsigned N>
HybridArray<T,N>::HybridArray(uint32 _capacity) :
HybridArray<T,N>::HybridArray(uint32_t _capacity) :
m_capacity(_capacity < N ? N : _capacity),
m_size(0)
{
Expand Down Expand Up @@ -205,7 +205,7 @@ namespace Jo {

// ********************************************************************* //
template<typename T, unsigned N>
typename HybridArray<T,N>::ElemType& HybridArray<T,N>::operator [] (uint32 _index)
typename HybridArray<T,N>::ElemType& HybridArray<T,N>::operator [] (uint32_t _index)
{
// TODO: logging system
assert(m_size > _index);
Expand All @@ -214,7 +214,7 @@ namespace Jo {
}

template<typename T, unsigned N>
const typename HybridArray<T,N>::ElemType& HybridArray<T,N>::operator [] (uint32 _index) const
const typename HybridArray<T,N>::ElemType& HybridArray<T,N>::operator [] (uint32_t _index) const
{
// TODO: logging system
assert(m_size > _index);
Expand All @@ -224,7 +224,7 @@ namespace Jo {

// ********************************************************************* //
template<typename T, unsigned N>
void HybridArray<T,N>::Resize(uint32 _capacity)
void HybridArray<T,N>::Resize(uint32_t _capacity)
{
// Resizing without change. Bad Performance!
// TODO: logging system
Expand All @@ -233,7 +233,7 @@ namespace Jo {
// Prune as much as possible
if( _capacity == 0 ) _capacity = m_size;

uint32 oldCapacity = m_capacity;
uint32_t oldCapacity = m_capacity;
m_capacity = _capacity < N ? N : _capacity;
// If both old and new capacity are <= N nothing happens otherwise
// a realloc or copy is necessary
Expand Down Expand Up @@ -292,7 +292,7 @@ namespace Jo {

// ********************************************************************* //
template<typename T, unsigned N>
const T& HybridArray<T,N>::Insert(uint32 _where, const ElemType& _element)
const T& HybridArray<T,N>::Insert(uint32_t _where, const ElemType& _element)
{
// Exponential growth if necessary
if( m_size == m_capacity ) Resize(m_capacity * 2);
Expand All @@ -305,7 +305,7 @@ namespace Jo {
}

template<typename T, unsigned N>
T& HybridArray<T,N>::Insert(uint32 _where, ElemType&& _element)
T& HybridArray<T,N>::Insert(uint32_t _where, ElemType&& _element)
{
// Exponential growth if necessary
if( m_size == m_capacity ) Resize(m_capacity * 2);
Expand Down
Loading

0 comments on commit d49773b

Please sign in to comment.