Skip to content

Commit

Permalink
First build commit
Browse files Browse the repository at this point in the history
* Added prototypes for create and destroy window
* Setup CPU, CUDA and OpenCL backends
* Added CMakeLists and CMakeModules
  • Loading branch information
shehzan10 committed Jan 3, 2015
1 parent 738a325 commit 70239dc
Show file tree
Hide file tree
Showing 50 changed files with 2,453 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
build*/
60 changes: 60 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
PROJECT(FIREWORKS)

OPTION(BUILD_CPU "Build FireWorks with a CPU backend" ON)
OPTION(BUILD_CUDA "Build FireWorks with a CUDA backend" OFF)
OPTION(BUILD_OPENCL "Build FireWorks with a OPENCL backend" OFF)

SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules")

INCLUDE_DIRECTORIES(
"${CMAKE_CURRENT_SOURCE_DIR}/include"
"${CMAKE_CURRENT_SOURCE_DIR}/src/backend"
"${CMAKE_CURRENT_SOURCE_DIR}/src/api/c"
)

IF(${UNIX})
ADD_DEFINITIONS(-Wall -std=c++11 -fvisibility=hidden)
ENDIF()

# OS Definitions
IF(UNIX)
IF(APPLE) #OSX
ADD_DEFINITIONS(-DOS_MAC)
ELSE(APPLE) #Linux
ADD_DEFINITIONS(-DOS_LNX)
ENDIF()
ELSE(${UNIX}) #Windows
ADD_DEFINITIONS(-DOS_WIN -DNOMINMAX)
ENDIF()

# Architechture Definitions
INCLUDE(${CMAKE_MODULE_PATH}/TargetArch.cmake)
target_architecture(ARCH)
IF(${ARCH} STREQUAL "x86_64")
ADD_DEFINITIONS(-DARCH_64)
ELSE(${ARCH})
ADD_DEFINITIONS(-DARCH_32)
ENDIF()

INCLUDE(${CMAKE_MODULE_PATH}/Version.cmake)

IF(${BUILD_CPU})
ADD_SUBDIRECTORY(src/backend/cpu)
ENDIF()

IF(${BUILD_CUDA})
ADD_SUBDIRECTORY(src/backend/cuda)
ENDIF()

IF(${BUILD_OPENCL})
ADD_SUBDIRECTORY(src/backend/opencl)
ENDIF()

## Install step
INSTALL(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/include/" DESTINATION include
FILES_MATCHING
PATTERN "*.h"
PATTERN "*.hpp"
PATTERN ".gitignore" EXCLUDE
)
37 changes: 37 additions & 0 deletions CMakeModules/CUDACheckCompute.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#############################
#Sourced from:
#https://raw.githubusercontent.com/jwetzl/CudaLBFGS/master/CheckComputeCapability.cmake
#############################
# Check for GPUs present and their compute capability
# based on http://stackoverflow.com/questions/2285185/easiest-way-to-test-for-existence-of-cuda-capable-gpu-from-cmake/2297877#2297877 (Christopher Bruns)

if(CUDA_FOUND)
message(STATUS "${CMAKE_MODULE_PATH}/cuda_compute_capability.c")
try_run(RUN_RESULT_VAR COMPILE_RESULT_VAR
${CMAKE_BINARY_DIR}
${CMAKE_MODULE_PATH}/cuda_compute_capability.c
CMAKE_FLAGS
-DINCLUDE_DIRECTORIES:STRING=${CUDA_TOOLKIT_INCLUDE}
-DLINK_LIBRARIES:STRING=${CUDA_CUDART_LIBRARY}
COMPILE_OUTPUT_VARIABLE COMPILE_OUTPUT_VAR
RUN_OUTPUT_VARIABLE RUN_OUTPUT_VAR)
message(STATUS "Compile: ${RUN_OUTPUT_VAR}")
if (COMPILE_RESULT_VAR)
message(STATUS "compiled -> " ${RUN_RESULT_VAR})
else()
message(STATUS "didn't compile")
endif()
# COMPILE_RESULT_VAR is TRUE when compile succeeds
# RUN_RESULT_VAR is zero when a GPU is found
if(COMPILE_RESULT_VAR AND NOT RUN_RESULT_VAR)
message(STATUS "worked")
set(CUDA_HAVE_GPU TRUE CACHE BOOL "Whether CUDA-capable GPU is present")
set(CUDA_COMPUTE_CAPABILITY ${RUN_OUTPUT_VAR} CACHE STRING "Compute capability of CUDA-capable GPU present")
set(CUDA_GENERATE_CODE "arch=compute_${CUDA_COMPUTE_CAPABILITY},code=sm_${CUDA_COMPUTE_CAPABILITY}" CACHE STRING "Which GPU architectures to generate code for (each arch/code pair will be passed as --generate-code option to nvcc, separate multiple pairs by ;)")
mark_as_advanced(CUDA_COMPUTE_CAPABILITY CUDA_GENERATE_CODE)
set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} -arch compute_${CUDA_COMPUTE_CAPABILITY})
else()
message(STATUS "didn't work")
set(CUDA_HAVE_GPU FALSE CACHE BOOL "Whether CUDA-capable GPU is present")
endif()
endif()
33 changes: 33 additions & 0 deletions CMakeModules/FindBoostCompute.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Downloads and builds the Boost Compute library from github.com
# Defines the following variables
# * BoostCompute_FOUND Flag for Boost Compute
# * BoostCompute_INCLUDE_DIR Location of the Boost Compute headers

# Look a directory above for the Boost Compute folder
FIND_PATH( BoostCompute_SOURCE_DIR
NAMES include/boost/compute.hpp
PATH_SUFFIXES compute BoostCompute
DOC "Location of the Boost Compute source directory"
PATHS ${CMAKE_SOURCE_DIR}/..
${CMAKE_SOURCE_DIR}/../..
/usr/local)

FIND_PATH( BoostCompute_INCLUDE_DIR
NAMES boost/compute.hpp
DOC "Location of the Boost Compute include directory."
PATHS ${BoostCompute_SOURCE_DIR}/include)

IF(BoostCompute_INCLUDE_DIR AND BoostCompute_SOURCE_DIR)
SET( BoostCompute_FOUND ON CACHE BOOL "BoostCompute Found" )
ELSE()
SET( BoostCompute_FOUND OFF CACHE BOOL "BoostCompute Found" )
ENDIF()

IF(NOT BoostCompute_FOUND)
MESSAGE(FATAL_ERROR, "Boost.Compute not found! Clone Boost.Compute from https://github.com/kylelutz/compute.git")
ENDIF(NOT BoostCompute_FOUND)

MARK_AS_ADVANCED(
BoostCompute_FOUND
BoostCompute_INCLUDE_DIR
)
55 changes: 55 additions & 0 deletions CMakeModules/FindGLEWmx.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Source from
#https://github.com/LaurentGomila/SFML/blob/master/cmake/Modules/FindGLEW.cmake

#
# Try to find GLEW library and include path.
# Once done this will define
#
# GLEW_FOUND
# GLEW_INCLUDE_DIR
# GLEW_LIBRARY
# GLEWmx_LIBRARY
#
FIND_PACKAGE(GLEW)
FIND_PACKAGE(OpenGL)

IF (WIN32)
IF (NV_SYSTEM_PROCESSOR STREQUAL "AMD64")
FIND_LIBRARY( GLEWmx_LIBRARY
NAMES glew64mx glew64mxs
PATHS
$ENV{PROGRAMFILES}/GLEW/lib
${PROJECT_SOURCE_DIR}/src/nvgl/glew/bin
${PROJECT_SOURCE_DIR}/src/nvgl/glew/lib
DOC "The GLEWmx library (64-bit)"
)
ELSE(NV_SYSTEM_PROCESSOR STREQUAL "AMD64")
FIND_LIBRARY( GLEWmx_LIBRARY
NAMES glewmx GLEWmx glew32mx glew32mxs
PATHS
$ENV{PROGRAMFILES}/GLEW/lib
${PROJECT_SOURCE_DIR}/src/nvgl/glew/bin
${PROJECT_SOURCE_DIR}/src/nvgl/glew/lib
DOC "The GLEWmx library"
)
ENDIF(NV_SYSTEM_PROCESSOR STREQUAL "AMD64")
ELSE (WIN32)
FIND_LIBRARY( GLEWmx_LIBRARY
NAMES GLEWmx glewmx
PATHS
/usr/lib64
/usr/lib
/usr/lib/x86_64-linux-gnu
/usr/lib/arm-linux-gnueabihf
/usr/local/lib64
/usr/local/lib
/sw/lib
/opt/local/lib
${GLEW_ROOT_DIR}/lib
NO_DEFAULT_PATH
DOC "The GLEWmx library")
ENDIF (WIN32)

IF (GLEW_INCLUDE_DIR AND GLEWmx_LIBRARY)
SET(GLEWmx_FOUND "YES")
ENDIF (GLEW_INCLUDE_DIR AND GLEWmx_LIBRARY)
54 changes: 54 additions & 0 deletions CMakeModules/FindGLFW.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Sourced from
#https://code.google.com/p/assembly3d/

# Locate the glfw library
# This module defines the following variables:
# GLFW_LIBRARY, the name of the library;
# GLFW_INCLUDE_DIR, where to find glfw include files.
# GLFW_FOUND, true if both the GLFW_LIBRARY and GLFW_INCLUDE_DIR have been found.
#
# To help locate the library and include file, you could define an environment variable called
# GLFW_ROOT which points to the root of the glfw library installation. This is pretty useful
# on a Windows platform.
#
#
# Usage example to compile an "executable" target to the glfw library:
#
# FIND_PACKAGE (glfw REQUIRED)
# INCLUDE_DIRECTORIES (${GLFW_INCLUDE_DIR})
# ADD_EXECUTABLE (executable ${EXECUTABLE_SRCS})
# TARGET_LINK_LIBRARIES (executable ${GLFW_LIBRARY})
#
# TODO:
# Allow the user to select to link to a shared library or to a static library.

#Search for the include file...
FIND_PATH(GLFW_INCLUDE_DIR GLFW/glfw3.h DOC "Path to GLFW include directory."
HINTS
$ENV{GLFW_ROOT}
PATH_SUFFIX include #For finding the include file under the root of the glfw expanded archive, typically on Windows.
PATHS
/usr/include/
/usr/local/include/
# By default headers are under GLFW subfolder
/usr/include/GLFW
/usr/local/include/GLFW
${GLFW_ROOT_DIR}/include/ # added by ptr
)

FIND_LIBRARY(GLFW_LIBRARY DOC "Absolute path to GLFW library."
NAMES glfw GLFW.lib
HINTS
$ENV{GLFW_ROOT}
PATH_SUFFIXES lib/win32 #For finding the library file under the root of the glfw expanded archive, typically on Windows.
PATHS
/usr/local/lib
/usr/lib
${GLFW_ROOT_DIR}/lib-msvc100/release # added by ptr
)

SET(GLFW_FOUND 0)
IF(GLFW_LIBRARY AND GLFW_INCLUDE_DIR)
SET(GLFW_FOUND 1)
message(STATUS "GLFW found!")
ENDIF(GLFW_LIBRARY AND GLFW_INCLUDE_DIR)
Loading

0 comments on commit 70239dc

Please sign in to comment.