Skip to content

Commit 516f1cc

Browse files
committed
add c++14 as an option to cmake
1 parent 9ed70f9 commit 516f1cc

8 files changed

Lines changed: 36 additions & 11 deletions

File tree

CMakeLists.txt

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,24 @@ else ()
144144
endif ()
145145

146146

147+
#[[
148+
!!/ **-DSTD (std) = 11**
149+
!!/
150+
!!/ C++ syntax standard. The source code is c++11-compliant, and should have no
151+
!!/ problems compiled with c++14. If set to *14* here, users should make sure
152+
!!/ the compilers are c++14-compliant.
153+
!!/
154+
]]
155+
if (DEFINED ENV{std})
156+
set (stdValue $ENV{std})
157+
else ()
158+
set (stdValue 11)
159+
endif ()
160+
set (STD ${stdValue} CACHE STRING "C++ standard: 11 and 14.")
161+
set_property (CACHE STD PROPERTY STRINGS 11 14)
162+
set (T9_CPPSTD ${STD})
163+
164+
147165
#[[
148166
!!/ **-DPREC (prec) = mixed**
149167
!!/
@@ -238,7 +256,7 @@ else ()
238256
set (compCapValue 60,70)
239257
endif ()
240258
set (COMPUTE_CAPABILITY ${compCapValue} CACHE STRING
241-
"CUDA Compute Capability Multiplied by 10 (Comma-Separated)"
259+
"[GPU ONLY] CUDA Compute Capability Multiplied by 10 (Comma-Separated)"
242260
)
243261
## Compute Capability 60,70 -> 60;70
244262
string (REPLACE "," ";" T9_CUCCLIST ${COMPUTE_CAPABILITY}) # 60;70
@@ -273,7 +291,7 @@ elseif (DEFINED ENV{CUDACXX})
273291
else ()
274292
set (cudaDirValue /usr/local/cuda)
275293
endif ()
276-
set (CUDA_DIR ${cudaDirValue} CACHE PATH "CUDA Directory")
294+
set (CUDA_DIR ${cudaDirValue} CACHE PATH "[GPU ONLY] CUDA Directory")
277295
## cuda compiler
278296
## set CMAKE_CUDA_COMPILER before project ()
279297
if (NOT HOST)
@@ -298,7 +316,7 @@ if (DEFINED ENV{fftw_dir})
298316
else ()
299317
set (fftwDirValue "${CMAKE_BINARY_DIR}/fftw")
300318
endif ()
301-
set (FFTW_DIR ${fftwDirValue} CACHE PATH "FFTW3 Directory")
319+
set (FFTW_DIR ${fftwDirValue} CACHE PATH "[CPU ONLY] FFTW3 Directory")
302320

303321

304322
#[[
@@ -553,6 +571,7 @@ ExternalProject_Add (src-acc
553571
"-DCMAKE_CXX_COMPILER=${T9_ACC_COMPILER}"
554572
"-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}"
555573
"-DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/src-acc"
574+
"-DT9_CPPSTD=${T9_CPPSTD}"
556575
"-DT9_SYS_INCPATH=${T9_EP_ACC_SYS_INCPATH}"
557576
"-DT9_INCPATH=${T9_EP_ACC_INCPATH}"
558577
"-DT9_ACC_DEFS=${T9_EP_ACC_MACRO}"
@@ -583,7 +602,7 @@ add_library (__t9_all_tests_o OBJECT ${T9_TEST_SRC})
583602
target_compile_definitions (__t9_all_tests_o PRIVATE ${T9_DEFS})
584603
set_target_properties (__t9_all_tests_o PROPERTIES
585604
CXX_STANDARD
586-
11
605+
${T9_CPPSTD}
587606
)
588607
target_include_directories (__t9_all_tests_o SYSTEM PRIVATE "${T9_SYS_INCPATH}")
589608
target_include_directories (__t9_all_tests_o PRIVATE

cmake/device.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
add_library (tinker9_main OBJECT src-main/main_tinker9.cpp)
22
set_target_properties (tinker9_main PROPERTIES
33
CXX_STANDARD
4-
11
4+
${T9_CPPSTD}
55
)
66
target_compile_definitions (tinker9_main PRIVATE "${T9_DEFS}")
77
target_include_directories (tinker9_main SYSTEM PRIVATE "${T9_SYS_INCPATH}")

cmake/host.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ add_executable (tinker9 src-main/main_tinker9.cpp)
22
add_dependencies (tinker9 src-acc src-libtinker)
33
set_target_properties (tinker9 PROPERTIES
44
CXX_STANDARD
5-
11
5+
${T9_CPPSTD}
66
)
77
target_compile_definitions (tinker9 PRIVATE "${T9_DEFS}")
88
target_include_directories (tinker9 SYSTEM PRIVATE "${T9_SYS_INCPATH}")

doc/manual/m/install/buildwithcmake.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,12 @@ Install the executables under *${CMAKE_INSTALL_PREFIX}*. If this option is
8585
not set, *make install* is configured not to install anything, which is
8686
different from the default cmake behavior to install the program under */usr/local*.
8787

88+
**-DSTD (std) = 11**
89+
90+
C++ syntax standard. The source code is c++11-compliant, and should have no
91+
problems compiled with c++14. If set to *14* here, users should make sure
92+
the compilers are c++14-compliant.
93+
8894
**-DPREC (prec) = mixed**
8995

9096
Precision of the floating-point numbers. With flag *double*/*d*, all of the

src-acc/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ file (GLOB __T9_ACC_SRC "*_acc.cpp")
2323
add_library (tinker9_acc STATIC "${__T9_ACC_SRC}")
2424
set_target_properties (tinker9_acc PROPERTIES
2525
CXX_STANDARD
26-
11
26+
${T9_CPPSTD}
2727
)
2828
target_compile_definitions (tinker9_acc PRIVATE "${T9_ACC_DEFS}")
2929
target_include_directories (tinker9_acc SYSTEM PRIVATE "${T9_SYS_INCPATH}")

src-cu/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ file (GLOB __T9_CUDA_SRC "*_cu.cu")
1212
add_library (tinker9_cu STATIC "${__T9_CUDA_SRC}")
1313
set_target_properties (tinker9_cu PROPERTIES
1414
CUDA_STANDARD
15-
11
15+
${T9_CPPSTD}
1616
)
1717
target_compile_definitions (tinker9_cu PRIVATE ${T9_DEFS})
1818
target_include_directories (tinker9_cu SYSTEM PRIVATE "${T9_SYS_INCPATH}")

src/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ endif ()
1212
add_library (__t9_cpp_o OBJECT "${__T9_CPP_SRC}")
1313
set_target_properties (__t9_cpp_o PROPERTIES
1414
CXX_STANDARD
15-
11
15+
${T9_CPPSTD}
1616
)
1717
target_compile_definitions (__t9_cpp_o PRIVATE "${T9_DEFS}")
1818
target_include_directories (__t9_cpp_o SYSTEM PRIVATE "${T9_SYS_INCPATH}")
@@ -25,7 +25,7 @@ add_library (__t9_version_related_o OBJECT
2525
)
2626
set_target_properties (__t9_version_related_o PROPERTIES
2727
CXX_STANDARD
28-
11
28+
${T9_CPPSTD}
2929
)
3030
if (__T9_GIT_SHA1)
3131
target_compile_definitions (__t9_version_related_o PRIVATE

src/cudart/thrust_cache.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ ThrustCache::ThrustCache()
1212

1313
auto ThrustCache::allocate(ptrdiff_t numbyte) -> value_type*
1414
{
15-
if (numbyte > nbytes) {
15+
if ((size_t)numbyte > nbytes) {
1616
nbytes = numbyte;
1717
device_memory_deallocate_bytes(ptr);
1818
device_memory_allocate_bytes(reinterpret_cast<void**>(&ptr), nbytes);

0 commit comments

Comments
 (0)