#******************************************************************************************
#> [KAZOE]                                                                                 <
#> Initial Sofware by [Yannick Verdie, Florent Lafarge], Copyright (C) Inria (GEOMETRICA)  <
#> All Rights Reserved, 2012, [Version 1.0].                                               <
#******************************************************************************************

SET (PROJECT_NAME "Kazoe")

project (${PROJECT_NAME})

cmake_minimum_required(VERSION 2.8.8)#2.8.8 added support of curand ! required ! 

set( CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS true )

if( COMMAND cmake_policy )
  cmake_policy( SET CMP0003 NEW )  
endif()

FIND_PACKAGE(CUDA 4.1 REQUIRED)

if( NOT WIN32 )
SET(CMAKE_CXX_FLAGS  -Wfatal-errors)
endif()

set (PATH_CPU "${PROJECT_NAME} CPU")
set( SRCS_CPU 
"${PATH_CPU}/CPU_common_header.cpp" 
"${PATH_CPU}/DataTree.cpp"
"${PATH_CPU}/ParameterFile.cpp"
"${PATH_CPU}/Stat.cpp"
"${PATH_CPU}/Simulation_GPU.cpp"
)
SOURCE_GROUP("${PROJECT_NAME} CPU" FILES ${SRCS_CPU}) 



#here GPU
set (PATH_GPU "${PROJECT_NAME} GPU")
set( SRCS_GPU 
"${PATH_GPU}/GPU_Flamengo.cu" 
"${PATH_GPU}/GPU_main.cu")

SOURCE_GROUP("${PROJECT_NAME} GPU" FILES ${SRCS_GPU}) 

 SET(CMAKE_BUILD_TYPE Release)
 
if( CUDA_FOUND)

	option(CUDA_VERBOSE_PTXAS "On to enable verbose output from the PTXAS assembler." OFF)
	
	set(GENCODE_SM13 -gencode=arch=compute_13,code=sm_13 -gencode=arch=compute_13,code=compute_13)
	set(GENCODE_SM20 -gencode=arch=compute_20,code=sm_20 -gencode=arch=compute_20,code=compute_20)

	if (CUDA_VERBOSE_PTXAS)
		set(VERBOSE_PTXAS --ptxas-options=-v)
	endif (CUDA_VERBOSE_PTXAS)
	
	FIND_LIBRARY(CUDA_curand_LIBRARY curand HINTS "${CUDA_LIB_DIR}")
	
	include_directories (${PATH_CPU} ${PATH_GPU} "${PROJECT_NAME} 3rdparty") 
	cuda_add_executable(${PROJECT_NAME} main.cpp ${SRCS_CPU} ${SRCS_GPU} OPTIONS ${GENCODE_SM13} ${GENCODE_SM20} ${VERBOSE_PTXAS})
    TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${CUDA_LIBRARIES} ${CUDA_curand_LIBRARY} )

endif()