Skip to content

Commit

Permalink
Initial release
Browse files Browse the repository at this point in the history
  • Loading branch information
scheibel committed Mar 6, 2018
0 parents commit e4d7813
Show file tree
Hide file tree
Showing 42 changed files with 3,442 additions and 0 deletions.
41 changes: 41 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Compiled Object files
*.slo
*.lo
*.o

# Compiled Dynamic libraries
*.so
*.dylib

# Compiled Static libraries
*.lai
*.la
*.a

# Build dir
build*
debug_build
release_build
/bin
/lib
/install

# Qt cache
CMakeLists.txt.user
CMakeLists.txt.user.*

# IDE project files
*.sublime-project
*.sublime-workspace

# Local config windows
_configure.bat
_open-project.bat
_start-cmake-gui.bat
_start-cmd.bat

# Local config unix
.localconfig

# Taken screenshots
screenshots/*
2 changes: 2 additions & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

Willy Scheibel <[email protected]> <[email protected]>
173 changes: 173 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@

#
# CMake options
#

# CMake version
cmake_minimum_required(VERSION 3.0 FATAL_ERROR)

# Include cmake modules

list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
set(WriterCompilerDetectionHeaderFound NOTFOUND)

include(GenerateExportHeader)
include(ExternalProject)

# This module is only available with CMake >=3.1, so check whether it could be found
include(WriteCompilerDetectionHeader OPTIONAL RESULT_VARIABLE WriterCompilerDetectionHeaderFound)

include(cmake/GetGitRevisionDescription.cmake)
include(cmake/Custom.cmake)

# Set policies
set_policy(CMP0028 NEW) # ENABLE CMP0028: Double colon in target name means ALIAS or IMPORTED target.
set_policy(CMP0054 NEW) # ENABLE CMP0054: Only interpret if() arguments as variables or keywords when unquoted.
set_policy(CMP0042 NEW) # ENABLE CMP0042: MACOSX_RPATH is enabled by default.
set_policy(CMP0063 NEW) # ENABLE CMP0063: Honor visibility properties for all target types.


#
# Project description and (meta) information
#

# Get git revision
get_git_head_revision(GIT_REFSPEC GIT_SHA1)
string(SUBSTRING "${GIT_SHA1}" 0 12 GIT_REV)

# Meta information about the project
set(META_PROJECT_NAME "unifiedmemory")
set(META_PROJECT_DESCRIPTION "Unified Memory Heterogenous Computing Showcase")
set(META_AUTHOR_ORGANIZATION "CG Internals")
set(META_AUTHOR_DOMAIN "[email protected]:willy.scheibel/unifiedmemory.git")
set(META_AUTHOR_MAINTAINER "[email protected]")
set(META_VERSION_MAJOR "0")
set(META_VERSION_MINOR "0")
set(META_VERSION_PATCH "0")
set(META_VERSION_REVISION "${GIT_REV}")
set(META_VERSION "${META_VERSION_MAJOR}.${META_VERSION_MINOR}.${META_VERSION_PATCH}")
set(META_NAME_VERSION "${META_PROJECT_NAME} v${META_VERSION} (${META_VERSION_REVISION})")


#
# Project configuration options
#

# Project options
option(BUILD_SHARED_LIBS "Build shared instead of static libraries." ON)
option(OPTION_SELF_CONTAINED "Create a self-contained install with all dependencies." OFF)
option(OPTION_BUILD_DOCS "Build documentation." OFF)


#
# Declare project
#

# Generate folders for IDE targets (e.g., VisualStudio solutions)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
set(IDE_FOLDER "")

# Declare project
project(${META_PROJECT_NAME} C CXX)

# Set output directories
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR})
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR})

# Create version file
file(WRITE "${PROJECT_BINARY_DIR}/VERSION" "${META_NAME_VERSION}")


#
# Compiler settings and options
#

include(cmake/CompileOptions.cmake)


#
# Deployment/installation setup
#

# Get project name
set(project ${META_PROJECT_NAME})

# Check for system dir install
set(SYSTEM_DIR_INSTALL FALSE)
if("${CMAKE_INSTALL_PREFIX}" STREQUAL "/usr" OR "${CMAKE_INSTALL_PREFIX}" STREQUAL "/usr/local")
set(SYSTEM_DIR_INSTALL TRUE)
endif()

# Installation paths
if(UNIX AND SYSTEM_DIR_INSTALL)
# Install into the system (/usr/bin or /usr/local/bin)
set(INSTALL_ROOT "share/${project}") # /usr/[local]/share/<project>
set(INSTALL_CMAKE "share/${project}/cmake") # /usr/[local]/share/<project>/cmake
set(INSTALL_EXAMPLES "share/${project}") # /usr/[local]/share/<project>
set(INSTALL_DATA "share/${project}") # /usr/[local]/share/<project>
set(INSTALL_BIN "bin") # /usr/[local]/bin
set(INSTALL_SHARED "lib") # /usr/[local]/lib
set(INSTALL_LIB "lib") # /usr/[local]/lib
set(INSTALL_INCLUDE "include") # /usr/[local]/include
set(INSTALL_DOC "share/doc/${project}") # /usr/[local]/share/doc/<project>
set(INSTALL_SHORTCUTS "share/applications") # /usr/[local]/share/applications
set(INSTALL_ICONS "share/pixmaps") # /usr/[local]/share/pixmaps
set(INSTALL_INIT "/etc/init") # /etc/init (upstart init scripts)
else()
# Install into local directory
set(INSTALL_ROOT ".") # ./
set(INSTALL_CMAKE "cmake") # ./cmake
set(INSTALL_EXAMPLES ".") # ./
set(INSTALL_DATA ".") # ./
set(INSTALL_BIN ".") # ./
set(INSTALL_SHARED "lib") # ./lib
set(INSTALL_LIB "lib") # ./lib
set(INSTALL_INCLUDE "include") # ./include
set(INSTALL_DOC "doc") # ./doc
set(INSTALL_SHORTCUTS "misc") # ./misc
set(INSTALL_ICONS "misc") # ./misc
set(INSTALL_INIT "misc") # ./misc
endif()

# Set runtime path
set(CMAKE_SKIP_BUILD_RPATH FALSE) # Add absolute path to all dependencies for BUILD
set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE) # Use CMAKE_INSTALL_RPATH for INSTALL
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH FALSE) # Do NOT add path to dependencies for INSTALL

if(NOT SYSTEM_DIR_INSTALL)
# Find libraries relative to binary
if(APPLE)
set(CMAKE_INSTALL_RPATH "@loader_path/../../../${INSTALL_LIB}")
else()
set(CMAKE_INSTALL_RPATH "$ORIGIN/${INSTALL_LIB}")
endif()
endif()


#
# Project modules
#

add_subdirectory(source)
add_subdirectory(docs)
add_subdirectory(deploy)


#
# Deployment (global project files)
#

# Install version file
install(FILES "${PROJECT_BINARY_DIR}/VERSION" DESTINATION ${INSTALL_ROOT} COMPONENT runtime)

# Install cmake find script for the project
install(FILES ${META_PROJECT_NAME}-config.cmake DESTINATION ${INSTALL_ROOT} COMPONENT dev)

# Install the project meta files
install(FILES AUTHORS DESTINATION ${INSTALL_ROOT} COMPONENT runtime)
install(FILES LICENSE DESTINATION ${INSTALL_ROOT} COMPONENT runtime)
install(FILES README.md DESTINATION ${INSTALL_ROOT} COMPONENT runtime)

# Install runtime data
install(DIRECTORY ${PROJECT_SOURCE_DIR}/data DESTINATION ${INSTALL_DATA} COMPONENT runtime)
20 changes: 20 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@

Copyright (c) 2017-2018 CG Internals

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Unified Memory Heterogenous Computing Showcase
148 changes: 148 additions & 0 deletions cmake/CompileOptions.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@

#
# Platform and architecture setup
#

# Get upper case system name
string(TOUPPER ${CMAKE_SYSTEM_NAME} SYSTEM_NAME_UPPER)

# Determine architecture (32/64 bit)
set(X64 OFF)
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(X64 ON)
endif()


#
# Project options
#

set(DEFAULT_PROJECT_OPTIONS
DEBUG_POSTFIX "d"
CXX_STANDARD 14 # Not available before CMake 3.1; see below for manual command line argument addition
LINKER_LANGUAGE "CXX"
POSITION_INDEPENDENT_CODE ON
CXX_VISIBILITY_PRESET "hidden"
)


#
# Include directories
#

set(DEFAULT_INCLUDE_DIRECTORIES)


#
# Libraries
#

set(DEFAULT_LIBRARIES)


#
# Compile definitions
#

set(DEFAULT_COMPILE_DEFINITIONS
SYSTEM_${SYSTEM_NAME_UPPER}
)

# MSVC compiler options
if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "MSVC")
set(DEFAULT_COMPILE_DEFINITIONS ${DEFAULT_COMPILE_DEFINITIONS}
_SCL_SECURE_NO_WARNINGS # Calling any one of the potentially unsafe methods in the Standard C++ Library
_CRT_SECURE_NO_WARNINGS # Calling any one of the potentially unsafe methods in the CRT Library
)
endif ()


#
# Compile options
#

set(DEFAULT_COMPILE_OPTIONS)

# MSVC compiler options
if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "MSVC")
set(DEFAULT_COMPILE_OPTIONS ${DEFAULT_COMPILE_OPTIONS}
/MP # -> build with multiple processes
/W4 # -> warning level 4
# /WX # -> treat warnings as errors

/wd4251 # -> disable warning: 'identifier': class 'type' needs to have dll-interface to be used by clients of class 'type2'
/wd4592 # -> disable warning: 'identifier': symbol will be dynamically initialized (implementation limitation)
# /wd4201 # -> disable warning: nonstandard extension used: nameless struct/union (caused by GLM)
# /wd4127 # -> disable warning: conditional expression is constant (caused by Qt)

#$<$<CONFIG:Debug>:
#/RTCc # -> value is assigned to a smaller data type and results in a data loss
#>

$<$<CONFIG:Release>:
/Gw # -> whole program global optimization
/GS- # -> buffer security check: no
/GL # -> whole program optimization: enable link-time code generation (disables Zi)
/GF # -> enable string pooling
>

# No manual c++11 enable for MSVC as all supported MSVC versions for cmake-init have C++11 implicitly enabled (MSVC >=2013)
)
endif ()

# GCC and Clang compiler options
if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU" OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
set(DEFAULT_COMPILE_OPTIONS ${DEFAULT_COMPILE_OPTIONS}
-Wall
-Wextra
-Wunused

-Wreorder
-Wignored-qualifiers
-Wmissing-braces
-Wreturn-type
-Wswitch
-Wswitch-default
-Wuninitialized
-Wmissing-field-initializers

$<$<CXX_COMPILER_ID:GNU>:
-Wmaybe-uninitialized

$<$<VERSION_GREATER:$<CXX_COMPILER_VERSION>,4.8>:
-Wpedantic

-Wreturn-local-addr
>
>

$<$<CXX_COMPILER_ID:Clang>:
-Wpedantic

-Wreturn-stack-address
>

$<$<PLATFORM_ID:Darwin>:
-pthread
>

# Required for CMake < 3.1; should be removed if minimum required CMake version is raised.
$<$<VERSION_LESS:${CMAKE_VERSION},3.1>:
-std=c++14
>
)
endif ()


#
# Linker options
#

set(DEFAULT_LINKER_OPTIONS)

# Use pthreads on mingw and linux
if("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU" OR "${CMAKE_SYSTEM_NAME}" MATCHES "Linux")
set(DEFAULT_LINKER_OPTIONS
-pthread
)
endif()
6 changes: 6 additions & 0 deletions cmake/ComponentInstall.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

# Execute cmake_install.cmake wrapper that allows to pass both DESTDIR and COMPONENT environment variable

execute_process(
COMMAND ${CMAKE_COMMAND} -DCOMPONENT=$ENV{COMPONENT} -P cmake_install.cmake
)
Loading

0 comments on commit e4d7813

Please sign in to comment.