11# CMake below 3.4 does not work with CUDA separable compilation at all
2- cmake_minimum_required (VERSION 3.4 )
2+ cmake_minimum_required (VERSION 3.12 )
33
4- project (PopSift VERSION 1.0.0)
4+ project (PopSift VERSION 1.0.0 LANGUAGES CXX)
5+
6+ # Set build path as a folder named as the platform (linux, windows, darwin...) plus the processor type
7+ set (EXECUTABLE_OUTPUT_PATH "${PROJECT_BINARY_DIR} /${CMAKE_SYSTEM_NAME} -${CMAKE_SYSTEM_PROCESSOR} " )
8+ set (LIBRARY_OUTPUT_PATH "${PROJECT_BINARY_DIR} /${CMAKE_SYSTEM_NAME} -${CMAKE_SYSTEM_PROCESSOR} " )
9+
10+ option (PopSift_BUILD_EXAMPLES "Build PopSift applications." ON )
11+ option (PopSift_USE_NVTX_PROFILING "Use CUDA NVTX for profiling." OFF )
12+ option (PopSift_ERRCHK_AFTER_KERNEL "Synchronize and check CUDA error after every kernel." OFF )
13+ option (PopSift_USE_POSITION_INDEPENDENT_CODE "Generate position independent code." ON )
14+ option (PopSift_USE_GRID_FILTER "Switch off grid filtering to massively reduce compile time while debugging other things." ON )
15+ option (PopSift_USE_NORMF "The __normf function computes Euclidian distance on large arrays. Fast but stability is uncertain." OFF )
16+ option (PopSift_USE_TEST_CMD "Add testing step for functional verification" OFF )
17+ option (PopSift_BOOST_USE_STATIC_LIBS "Link with static Boost libraries" OFF )
18+ option (PopSift_NVCC_WARNINGS "Switch on several additional warning for CUDA nvcc" OFF )
19+ option (BUILD_SHARED_LIBS "Build shared libraries" ON )
520
6- OPTION (PopSift_BUILD_EXAMPLES "Build PopSift applications." ON )
7- OPTION (PopSift_USE_NVTX_PROFILING "Use CUDA NVTX for profiling." OFF )
8- OPTION (PopSift_ERRCHK_AFTER_KERNEL "Synchronize and check CUDA error after every kernel." OFF )
9- OPTION (PopSift_USE_POSITION_INDEPENDENT_CODE "Generate position independent code." ON )
10- OPTION (PopSift_USE_GRID_FILTER "Switch off grid filtering to massively reduce compile time while debugging other things." ON )
11- OPTION (PopSift_USE_NORMF "The __normf function computes Euclidian distance on large arrays. Fast but stability is uncertain." OFF )
12- OPTION (PopSift_USE_TEST_CMD "Add testing step for functional verification" OFF )
13- OPTION (PopSift_BOOST_USE_STATIC_LIBS "Link with static Boost libraries" OFF )
14- OPTION (PopSift_NVCC_WARNINGS "Switch on several additional warning for CUDA nvcc" OFF )
1521
1622if (PopSift_BOOST_USE_STATIC_LIBS)
1723 set (Boost_USE_STATIC_LIBS ON )
@@ -31,15 +37,24 @@ else()
3137 message (STATUS "Building in ${CMAKE_BUILD_TYPE} configuration" )
3238endif ()
3339
34- set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3" )
35- set (CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -O3" )
40+ # for some reason this line is necessary to propagate the standard to nvcc
3641set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11" )
3742set (CMAKE_CXX_STANDARD 11)
3843set (CMAKE_CXX_STANDARD_REQUIRED ON )
44+ set (CMAKE_CUDA_STANDARD 11)
45+ set (CMAKE_CUDA_STANDARD_REQUIRED ON )
46+
47+ # ==============================================================================
48+ # GNUInstallDirs CMake module
49+ # - Define GNU standard installation directories
50+ # - Provides install directory variables as defined by the GNU Coding Standards.
51+ # ==============================================================================
52+ include (GNUInstallDirs)
3953
40- # set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -G")
41- # set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -G")
4254
55+ #################
56+ # BOOST
57+ #################
4358find_package (Boost 1.53.0 REQUIRED COMPONENTS system thread)
4459if (WIN32 )
4560 add_definitions ("-DBOOST_ALL_NO_LIB" )
6277 set (CUDA_USE_STATIC_CUDA_RUNTIME ON )
6378endif ()
6479
80+ ###################
81+ # CUDA
82+ ###################
6583find_package (CUDA 7.0 REQUIRED)
6684
6785if (NOT CUDA_FOUND)
@@ -145,9 +163,9 @@ if( ( CUDA_VERSION VERSION_EQUAL "7.5" ) OR ( CUDA_VERSION VERSION_GREATER "7.5"
145163endif ()
146164
147165if (PopSift_USE_NORMF AND CUDA_VERSION VERSION_GREATER "7.4" )
148- set (HAVE_NORMF 1)
166+ set (PopSift_HAVE_NORMF 1)
149167else ()
150- set (HAVE_NORMF 0)
168+ set (PopSift_HAVE_NORMF 0)
151169endif ()
152170
153171if ( ( CUDA_VERSION VERSION_EQUAL "9.0" ) OR ( CUDA_VERSION VERSION_GREATER "9.0" ) )
@@ -169,7 +187,9 @@ cuda_find_library_local_first(CUDA_CUDADEVRT_LIBRARY cudadevrt "\"cudadevrt\" li
169187if (PopSift_USE_NVTX_PROFILING)
170188 # library required for NVTX profiling of the CPU
171189 cuda_find_library_local_first(CUDA_NVTX_LIBRARY nvToolsExt "NVTX library" )
172- add_definitions (-DUSE_NVTX)
190+ set (PopSift_USE_NVTX 1)
191+ else ()
192+ set (PopSift_USE_NVTX 0)
173193endif ()
174194
175195add_subdirectory (src)
@@ -184,5 +204,27 @@ CONFIGURE_FILE(
184204 "${CMAKE_CURRENT_BINARY_DIR} /cmake/cmake_uninstall.cmake"
185205 IMMEDIATE @ONLY)
186206ADD_CUSTOM_TARGET (uninstall
187- "${CMAKE_COMMAND} " -P "${CMAKE_CURRENT_BINARY_DIR} /cmake/cmake_uninstall.cmake" )
188-
207+ "${CMAKE_COMMAND} " -P "${CMAKE_CURRENT_BINARY_DIR} /cmake/cmake_uninstall.cmake" )
208+
209+
210+ ######################################
211+ # SUMMARY
212+ ######################################
213+ message ("\n " )
214+ message ("******************************************" )
215+ message ("Building configuration:\n " )
216+ message (STATUS "PopSift version: " ${PROJECT_VERSION} )
217+ message (STATUS "Build type: " ${CMAKE_BUILD_TYPE} )
218+ message (STATUS "Build Shared libs: " ${BUILD_SHARED_LIBS} )
219+ message (STATUS "Build examples: " ${PopSift_BUILD_EXAMPLES} )
220+ message (STATUS "Generate position independent code: " ${PopSift_USE_POSITION_INDEPENDENT_CODE} )
221+ message (STATUS "Use CUDA NVTX for profiling: " ${PopSift_USE_NVTX_PROFILING} )
222+ message (STATUS "Synchronize and check CUDA error after every kernel: " ${PopSift_ERRCHK_AFTER_KERNEL} )
223+ message (STATUS "Grid filtering: " ${PopSift_USE_GRID_FILTER} )
224+ message (STATUS "Testing step: " ${PopSift_USE_TEST_CMD} )
225+ message (STATUS "Link with static Boost libraries: " ${PopSift_BOOST_USE_STATIC_LIBS} )
226+ message (STATUS "Additional warning for CUDA nvcc: " ${PopSift_NVCC_WARNINGS} )
227+ message (STATUS "Compiling for CUDA CCs: ${PopSift_CUDA_CC_LIST} " )
228+ message (STATUS "Install path: " ${CMAKE_INSTALL_PREFIX} )
229+ message ("\n ******************************************" )
230+ message ("\n " )
0 commit comments