File tree Expand file tree Collapse file tree 2 files changed +10
-0
lines changed
Expand file tree Collapse file tree 2 files changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ set_property(CACHE BUILD_OPENGL PROPERTY STRINGS AUTO ON OFF)
88option (BUILD_SHARED_LIBS "Build using shared libraries" ON )
99option (CMAKE_CUDA_ARCHITECTURES "CUDA architectures to build for (needs CMake 3.18)" OFF )
1010option (ENABLE_FPNGE "Enable fpnge - requires c++ and sse4" OFF )
11+ option (USE_NATIVE_CPU_ARCH "Use -march=native for compilation (Linux only)" OFF )
1112option (HUFFMAN_GPU_CONST_TABLES "Enable Huffman GPU decoder quick const tables" OFF )
1213set (OPENGL_CONTEXT AUTO CACHE STRING "Use specifiedn OpenGL context creation, options are: AUTO GLX GLFW NONE" )
1314set_property (CACHE OPENGL_CONTEXT PROPERTY STRINGS AUTO GLX GLFW NONE )
@@ -78,6 +79,12 @@ if(ENABLE_FPNGE)
7879 file(GLOB_RECURSE CXX_FILES src/*.cc src/*.cpp)
7980endif()
8081
82+ if(USE_NATIVE_CPU_ARCH)
83+ set(CMAKE_C_FLAGS " ${CMAKE_C_FLAGS} -march=native ")
84+ set(CMAKE_CXX_FLAGS " ${CMAKE_CXX_FLAGS} -march=native ")
85+ set(CMAKE_CUDA_FLAGS " ${CMAKE_CUDA_FLAGS} -Xcompiler -march=native ")
86+ endif()
87+
8188# allow passing <PackageName>_ROOT to find_package()
8289if(POLICY CMP0074)
8390 cmake_policy(SET CMP0074 NEW)
Original file line number Diff line number Diff line change @@ -191,6 +191,9 @@ files are placed) and run `cmake` command:
191191 cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_CUDA_ARCHITECTURES=native -Bbuild .
192192 cmake --build build --config Release
193193
194+ In Linux, you may also consider ` -DUSE_NATIVE_CPU_ARCH=ON ` for optimized
195+ CPU code build (` -march=native ` added to compiler flags).
196+
194197In Linux, you can also use ** autotools** to create a build recipe for
195198the library and the application or a plain old _ Makefile.bkp_ . However,
196199_ cmake_ is recommended.
You can’t perform that action at this time.
0 commit comments