OPTIMIZE_DEPENDENCIES doesn't optimise basic case for Ninja
Consider the following minimal project
CMakeLists.txt
cmake_minimum_required(VERSION 3.19)
project(optdep)
add_library(myStatic STATIC func.cpp)
add_library(myShared SHARED impl.cpp)
target_link_libraries(myStatic PRIVATE myShared)
set_target_properties(myStatic PROPERTIES OPTIMIZE_DEPENDENCIES YES)
func.cpp
#include "impl.h"
int func()
{
return 42 + impl();
}
impl.cpp
#error I should not be built
impl.h
int impl();
Running CMake on the above project and building just the myStatic
target should result in func.cpp
being compiled and the myStatic
static library being built, but the myShared
library should NOT be built due to the OPTIMIZE_DEPENDENCIES
property on myStatic
. This works for the Unix Makefiles
, Xcode
and Visual Studio generators, but not for Ninja
. Ninja still tries to compile impl.cpp
.
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information