CMakeLists.txt 3.71 KB
#Specify the version being used aswell as the language
cmake_minimum_required(VERSION 2.8)

#Name your project here
project(ga-gpu)

#set the module directory
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}")

#default to release mode
if(NOT CMAKE_BUILD_TYPE) 
	set(CMAKE_BUILD_TYPE Release)
endif(NOT CMAKE_BUILD_TYPE)

#build the executable in the binary directory on MS Visual Studio
if ( MSVC )
	SET( CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG "${OUTPUT_DIRECTORY}")
	SET( CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE "${OUTPUT_DIRECTORY}")
endif ( MSVC )
#MAYBE REMOVE-----------------
#set C++11 flags if using GCC
if( CMAKE_COMPILER_IS_GNUCC )
#	SET( CMAKE_CXX_FLAGS "-std=c++11")
	set(CMAKE_CXX_FLAGS "-std=c++11 -D_FORCE_INLINES")
#	SET( CUDA_NVCC_FLAGS "-std=c++11")
endif( CMAKE_COMPILER_IS_GNUCC )

SET( CUDA_NVCC_FLAGS "--gpu-architecture=compute_50 --gpu-code=sm_50,compute_50")
#-----------------------------



#find packages-----------------------------------
#find OpenCV
find_package(OpenCV REQUIRED)
add_definitions(-DUSING_OPENCV)

#find the pthreads package
find_package(Threads)

#find the X11 package
find_package(X11)

#find the STIM library
find_package(STIM)

#find CUDA, mostly for LA stuff using cuBLAS
find_package(CUDA REQUIRED)

#find Boost for Unix-based file lists
if( CMAKE_COMPILER_IS_GNUCC )
	find_package(Boost COMPONENTS filesystem system)
	if(Boost_FOUND)
		include_directories(${Boost_INCLUDE_DIR})
	else()
		message(FATAL_ERROR "HSIproc requires Boost::filesystem and Boost::system when using GCC")
	endif()
endif()

#find FANN
#find_package(FANN REQUIRED)

#find the GLUT library for visualization
#find_package(OpenGL REQUIRED)
#find_package(GLUT REQUIRED)
#if(WIN32)
#	find_package(GLEW REQUIRED)
#	include_directories(${GLEW_INCLUDE_DIR})
#endif(WIN32)

#find LAPACK and supporting link_libraries
find_package(LAPACKE REQUIRED)

#include include directories
include_directories(${CUDA_INCLUDE_DIRS}
					${OpenCV_INCLUDE_DIRS}
					${LAPACKE_INCLUDE_DIR}
					${STIM_INCLUDE_DIRS}
					${OpenGL_INCLUDE_DIRS}
#					${GLUT_INCLUDE_DIR}
					${FANN_INCLUDE_DIRS}
					"${CMAKE_SOURCE_DIR}/src"
)

#Assign a variable for all of the header files in this project
include_directories("${CMAKE_SOURCE_DIR}/src")
#file(GLOB GACPU_H "${CMAKE_SOURCE_DIR}/src/gacpu/*.h")
file(GLOB GAGPU_H "${CMAKE_SOURCE_DIR}/src/*.h")
#file(GLOB GA_H "${CMAKE_SOURCE_DIR}/src/*.h")

#Assign source files to the appropriate variables to easily associate them with executables
#file(GLOB GA_CPU_SRC "${CMAKE_SOURCE_DIR}/src/gacpu/*.cpp")
file(GLOB GA_GPU_SRC "${CMAKE_SOURCE_DIR}/src/*.c*")


#create an executable file
cuda_add_executable(ga-gpu
		${GAGPU_H}
#		${GA_H}
		${GA_GPU_SRC}
)
target_link_libraries(ga-gpu ${CUDA_LIBRARIES}
						 ${CUDA_CUBLAS_LIBRARIES}
						 ${CUDA_CUFFT_LIBRARIES}
						 ${LAPACKE_LIBRARIES}
						 ${LAPACK_LIBRARIES}
						 ${BLAS_LIBRARIES}
						 ${CMAKE_THREAD_LIBS_INIT}
						 ${X11_LIBRARIES}
						 ${OpenCV_LIBS}
)


#create the PROC executable----------------------------------------------

#create an executable file
#add_executable(hsiga
#		${GACPU_H}
#		${GA_H}
#		${GA_CPU_SRC}
#)
#target_link_libraries(hsiga ${LAPACKE_LIBRARIES}
#						 ${LAPACK_LIBRARIES}
#						 ${BLAS_LIBRARIES}
#						 ${CMAKE_THREAD_LIBS_INIT}
#						 ${X11_LIBRARIES}
#						 ${OpenCV_LIBS}
#)



#if Boost is found, set an environment variable to use with preprocessor directives
if(Boost_FILESYSTEM_FOUND)
#	if(BUILD_GACPU)	
#		target_link_libraries(hsiga ${Boost_FILESYSTEM_LIBRARIES}
#					      ${Boost_SYSTEM_LIBRARY}
#		)
		#message(${Boost_FILESYSTEM_LIBRARIES})
#	endif(BUILD_GACPU)
#	if(BUILD_GAGPU)
	target_link_libraries(ga-gpu ${Boost_FILESYSTEM_LIBRARIES}
					 ${Boost_SYSTEM_LIBRARY}
	)
#	endif(BUILD_GAGPU)	
endif(Boost_FILESYSTEM_FOUND)