cheshirekow / cmake_format

Source code formatter for cmake listfiles.
GNU General Public License v3.0
962 stars 105 forks source link

Linter: Force keyword signature #230

Open blackliner opened 4 years ago

blackliner commented 4 years ago

Is there a way to force the usage of the keywords PRIVATE|PUBLIC|INTERFACE in commands like target_link_libraries?

I want to prevent mixes, and want to enforce the usage of said keywords, so things like this will not happen:

target_link_libraries(my_lib
PRIVATE Eigen3::Eigen
)
...
target_link_libraries(my_lib
  Catch2::Catch2 # PRIVATE missing here!!
)
CMake Error at CMakeLists.txt:36 (target_link_libraries):
  The keyword signature for target_link_libraries has already been used with
  the target "my_lib".  All uses of target_link_libraries with a
  target must be either all-keyword or all-plain.

  The uses of the keyword signature are here:

   * CMakeLists.txt:28 (target_link_libraries)
cheshirekow commented 3 years ago

Is there a way to force the usage ...

Not yet. That would be a handy feature though.