@@ -39,7 +39,13 @@ set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "${BUILD_TYPE}")
3939set (XMR-STAK_COMPILE "native" CACHE STRING "select CPU compute architecture" )
4040set_property (CACHE XMR-STAK_COMPILE PROPERTY STRINGS "native;generic" )
4141if (XMR-STAK_COMPILE STREQUAL "native" )
42- if (NOT CMAKE_CXX_COMPILER_ID MATCHES "MSVC" )
42+ if (CMAKE_CXX_COMPILER_ID MATCHES "MSVC" )
43+ #intentionally appending due to how MSVC collects options
44+ # this forces these three flags to override any previous
45+ set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Ox /GL /EHsc" )
46+ set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /Ox /GL /EHsc" )
47+ else ()
48+ # GCC and all other compilers
4349 set (CMAKE_CXX_FLAGS "-march=native -mtune=native ${CMAKE_CXX_FLAGS} " )
4450 set (CMAKE_C_FLAGS "-march=native -mtune=native ${CMAKE_C_FLAGS} " )
4551 endif ()
@@ -142,9 +148,11 @@ if(CUDA_ENABLE)
142148 set (CLANG_BUILD_FLAGS "${CLANG_BUILD_FLAGS} --cuda-gpu-arch=sm_${CUDA_ARCH_ELEM} " )
143149 endforeach ()
144150 elseif (CUDA_COMPILER STREQUAL "nvcc" )
145- # add c++11 for cuda
146- if (NOT CMAKE_CXX_FLAGS MATCHES "-std=c\\ +\\ +11" )
147- set (CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS} -std=c++11" )
151+ if (NOT CMAKE_CXX_COMPILER_ID MATCHES "MSVC" )
152+ # add c++11 for cuda, except Windows
153+ if (NOT CMAKE_CXX_FLAGS MATCHES "-std=c\\ +\\ +11" )
154+ set (CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS} -std=c++11" )
155+ endif ()
148156 endif ()
149157
150158 # avoid that nvcc in CUDA 8 complains about sm_20 pending removal
@@ -417,6 +425,10 @@ include_directories(BEFORE .)
417425set (CMAKE_POSITION_INDEPENDENT_CODE TRUE )
418426
419427if (CMAKE_CXX_COMPILER_ID MATCHES "MSVC" )
428+ # optimize linking
429+ set (CMAKE_STATIC_LINKER_FLAGS_RELEASE "${CMAKE_STATIC_LINKER_FLAGS_RELEASE} /LTCG" )
430+ set (CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} /LTCG /INCREMENTAL:NO /OPT:REF" )
431+ set (CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /LTCG /INCREMENTAL:NO /OPT:REF" )
420432 # remove warnings that f_open() is not save and f_open_s should be used
421433 add_definitions (-D_CRT_SECURE_NO_DEPRECATE )
422434 # disable min define to allow usage of std::min
@@ -579,4 +591,5 @@ if( NOT CMAKE_INSTALL_PREFIX STREQUAL PROJECT_BINARY_DIR )
579591else ()
580592 # this rule is used if the install prefix is the build directory
581593 install (CODE "MESSAGE(\" xmr-stak installed to folder 'bin'\" )" )
582- endif ()
594+ endif ()
595+ # vim: et sw=4 sts=4 ts=4:
0 commit comments