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

#Name your project here
project(siproc)

#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}")
	SET( LIBRARY_OUTPUT_DIRECTORY_DEBUG "${OUTPUT_DIRECTORY}")
	SET( LIBRARY_OUTPUT_DIRECTORY_RELEASE "${OUTPUT_DIRECTORY}")
	add_definitions(-D_CRT_SECURE_NO_WARNINGS)
	add_definitions(-D_SCL_SECURE_NO_WARNINGS)
endif ( MSVC )
#MAYBE REMOVE-----------------
#set C++11 flags if using GCC
if( CMAKE_COMPILER_IS_GNUCC )
	SET( CMAKE_CXX_FLAGS "-std=c++11")
	SET( CUDA_NVCC_FLAGS "-std=c++11")
endif( CMAKE_COMPILER_IS_GNUCC )
#-----------------------------

#find packages-----------------------------------
#find the pthreads package
find_package(Threads)

#find the X11 package
find_package(X11)

#find the STIM library
find_package(STIM REQUIRED)

#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})
		add_definitions(-DBOOST_PRECOMPILED)
	else()
		message(FATAL_ERROR "HSIproc requires Boost::filesystem and Boost::system when using GCC")
	endif()
else()
	find_package(Boost)
endif()

#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)
#if(MSVC)
#	message("Warning: VS2015 made a change to printf and scanf functions that requires linking to legacy_stdio_definitions.lib")
#endif()

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

#Assign source files to the appropriate variables to easily associate them with executables
file(GLOB HSIGLOBAL_SRC "${CMAKE_SOURCE_DIR}/src/*.cpp")
file(GLOB HSIPROC_SRC "${CMAKE_SOURCE_DIR}/src/proc/*.cpp")
file(GLOB STIM_CU "${STIM_INCLUDE_DIRS}/stim/envi/*.cu")
file(GLOB HSIVIEW_SRC  "${CMAKE_SOURCE_DIR}/src/view/*.cpp")
file(GLOB CARY_FTIR_SRC "${CMAKE_SOURCE_DIR}/src/cary-ftir/*.cpp")
file(GLOB SPERO_SRC "${CMAKE_SOURCE_DIR}/src/spero/*.cpp")
file(GLOB PROGRESS_SRC "${CMAKE_SOURCE_DIR}/src/progress_t.cpp")

#create the PROC executable----------------------------------------------
add_executable(siproc
		${HSIPROC_SRC}
		${HSIGLOBAL_SRC}
)

target_link_libraries(siproc ${CUDA_LIBRARIES}
							 ${CUDA_CUBLAS_LIBRARIES}
							 ${CUDA_CUFFT_LIBRARIES}
							 ${LAPACKE_LIBRARIES}
							 ${CMAKE_THREAD_LIBS_INIT}
							 ${X11_LIBRARIES}
)

#create the VIEW executable----------------------------------------------
add_executable(siview
			${HSIVIEW_SRC}
)
target_link_libraries(siview
			${CMAKE_THREAD_LIBS_INIT}
			${X11_LIBRARIES}
			${OPENGL_gl_LIBRARY}
			${OPENGL_glu_LIBRARY} 
			${GLUT_LIBRARIES}
)
if(WIN32)
	target_link_libraries(siview ${GLEW_GLEW_LIBRARY})
endif(WIN32)

#create instrument-specific subroutine executables
add_executable(cary-ftir
		${CARY_FTIR_SRC}
		${PROGRESS_SRC}
)
target_link_libraries(cary-ftir
		${CUDA_LIBRARIES}
		${CUDA_CUBLAS_LIBRARIES}
		${CUDA_CUFFT_LIBRARIES}
)

#create the Agilent system-specific subroutine executable
add_executable(spero
		${SPERO_SRC}
		${PROGRESS_SRC}
)
target_link_libraries(spero
		${CUDA_LIBRARIES}
		${CUDA_CUBLAS_LIBRARIES}
		${CUDA_CUFFT_LIBRARIES}
)

#if Boost is found, set an environment variable to use with preprocessor directives
if(Boost_FILESYSTEM_FOUND)
	target_link_libraries(siproc ${Boost_FILESYSTEM_LIBRARIES}
				      ${Boost_SYSTEM_LIBRARY}
	)
	target_link_libraries(siview 	
				${Boost_FILESYSTEM_LIBRARIES}
				${Boost_SYSTEM_LIBRARY}
	)
	target_link_libraries(spero
					${Boost_FILESYSTEM_LIBRARIES}
					${Boost_SYSTEM_LIBRARY}
	)

	target_link_libraries(cary-ftir
					${Boost_FILESYSTEM_LIBRARIES}
					${Boost_SYSTEM_LIBRARY}
	)
endif(Boost_FILESYSTEM_FOUND)