|
| 1 | +if(ENABLE_CCACHE AND NOT CMAKE_COMPILER_IS_CCACHE) |
| 2 | + # This works fine with Unix Makefiles and Ninja generators |
| 3 | + find_host_program(CCACHE_PROGRAM ccache) |
| 4 | + if(CCACHE_PROGRAM) |
| 5 | + message(STATUS "Looking for ccache - found (${CCACHE_PROGRAM})") |
| 6 | + get_property(__OLD_RULE_LAUNCH_COMPILE GLOBAL PROPERTY RULE_LAUNCH_COMPILE) |
| 7 | + if(__OLD_RULE_LAUNCH_COMPILE) |
| 8 | + message(STATUS "Can't replace CMake compiler launcher") |
| 9 | + else() |
| 10 | + set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${CCACHE_PROGRAM}") |
| 11 | + # NOTE: Actually this check doesn't work as expected. |
| 12 | + # "RULE_LAUNCH_COMPILE" is ignored by CMake during try_compile() step. |
| 13 | + # ocv_check_compiler_flag(CXX "" IS_CCACHE_WORKS) |
| 14 | + set(IS_CCACHE_WORKS 1) |
| 15 | + if(IS_CCACHE_WORKS) |
| 16 | + set(CMAKE_COMPILER_IS_CCACHE 1) |
| 17 | + else() |
| 18 | + message(STATUS "Unable to compile program with enabled ccache, reverting...") |
| 19 | + set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${__OLD_RULE_LAUNCH_COMPILE}") |
| 20 | + endif() |
| 21 | + else() |
| 22 | + message(STATUS "Looking for ccache - not found") |
| 23 | + endif() |
| 24 | + endif() |
| 25 | +endif() |
| 26 | + |
| 27 | +if((CMAKE_COMPILER_IS_CLANGCXX OR CMAKE_COMPILER_IS_CLANGCC OR CMAKE_COMPILER_IS_CCACHE) AND NOT CMAKE_GENERATOR MATCHES "Xcode") |
| 28 | + set(ENABLE_PRECOMPILED_HEADERS OFF CACHE BOOL "" FORCE) |
| 29 | +endif() |
| 30 | + |
1 | 31 | if(MINGW OR (X86 AND UNIX AND NOT APPLE))
|
2 | 32 | # mingw compiler is known to produce unstable SSE code with -O3 hence we are trying to use -O2 instead
|
3 | 33 | if(CMAKE_COMPILER_IS_GNUCXX)
|
@@ -111,6 +141,10 @@ if(CMAKE_COMPILER_IS_GNUCXX)
|
111 | 141 | add_extra_compiler_option(-pthread)
|
112 | 142 | endif()
|
113 | 143 |
|
| 144 | + if(CMAKE_COMPILER_IS_CLANGCXX) |
| 145 | + add_extra_compiler_option(-Qunused-arguments) |
| 146 | + endif() |
| 147 | + |
114 | 148 | if(OPENCV_WARNINGS_ARE_ERRORS)
|
115 | 149 | add_extra_compiler_option(-Werror)
|
116 | 150 | endif()
|
|
0 commit comments