cen
2018-11-23 12:07:01 UTC
I finished watching "Effective CMake" talk by Daniel Pfeifer from last
year and it seems to me it is the "GO TO" resource for best practices. A
quick scan of my CMakeLists.txt files and sure enough, I use
include_directories() and other "dont's". The problem is that none of
the things mentioned in the talk:
a) give any warnings when running cmake
b) are mentioned as bad practice in the docs
What I would prefer is that everytime a bad practice is used a big red
warning would be printed by CMake so I could see it and correct it.
Since CMake is apparently very slow deprecating things a solution
appeared in my mind after seeing the function wrap functionality. How
about a file called Effective.cmake which contains something like
(pseudocode):
function(include_directories input output)
message(DEPRECATION "Use target_include_directories() instead."
_include_directories(...)
endfunction()
function(set input output)
if (${ARG0} STREQUAL "CMAKE_CXX_FLAGS")
message(DEPRECATION "You probably shouldn't use this directly")
endif
_set(...)
endfunction()
...
then include(Effective.cmake) in your CMakeLists.txt to enable all
warnings. The effort here is to compile a list of existing bad practices
and wrap them (if such a thing is possible).
Does this approach seem reasonable? Is there an effort with similar
goals out in the wild which I should know about?
Best regards,
cen
--
Powered by www.kitware.com
Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ
Kitware offers various services to support the CMake community. For more information on each offering, please visit:
CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html
Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
Follow this link to subscribe/unsubscribe:
https://
year and it seems to me it is the "GO TO" resource for best practices. A
quick scan of my CMakeLists.txt files and sure enough, I use
include_directories() and other "dont's". The problem is that none of
the things mentioned in the talk:
a) give any warnings when running cmake
b) are mentioned as bad practice in the docs
What I would prefer is that everytime a bad practice is used a big red
warning would be printed by CMake so I could see it and correct it.
Since CMake is apparently very slow deprecating things a solution
appeared in my mind after seeing the function wrap functionality. How
about a file called Effective.cmake which contains something like
(pseudocode):
function(include_directories input output)
message(DEPRECATION "Use target_include_directories() instead."
_include_directories(...)
endfunction()
function(set input output)
if (${ARG0} STREQUAL "CMAKE_CXX_FLAGS")
message(DEPRECATION "You probably shouldn't use this directly")
endif
_set(...)
endfunction()
...
then include(Effective.cmake) in your CMakeLists.txt to enable all
warnings. The effort here is to compile a list of existing bad practices
and wrap them (if such a thing is possible).
Does this approach seem reasonable? Is there an effort with similar
goals out in the wild which I should know about?
Best regards,
cen
--
Powered by www.kitware.com
Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ
Kitware offers various services to support the CMake community. For more information on each offering, please visit:
CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html
Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
Follow this link to subscribe/unsubscribe:
https://