CMake commands are sometimes given in upper and lower case.
Previously uppercase commands had been required but now commands are
case-insensitive and lowercase commands are preferred. Conversion to lowercase
commands have been implemented in other open source projects such as ITK vxl
and BRAINSTools, and is the preferred style for KDE. Consistent style
practices help to improve readability and maintainability of code.
This was implemented with the shell script:
NOTE: MUST USE GNU compliant version of sed
cmake --help-command-list \
| grep -v "cmake version" \
| while read c; do
echo 's/\b'"$(echo $c | tr '[:lower:]' '[:upper:]')"'\(\s*\)(/'"$c"'\1(/g'
done >convert.sed \
&& git ls-files -z -- bootstrap '*.cmake' '*.cmake.in' '*CMakeLists.txt' \
| xargs -0 gsed -i -f convert.sed \
&& rm convert.sed
This is a reimplementation of ITK commit
896f6b9220255bed1b3a1409af5257146b54e261
STYLE: Convert CMake-language commands lower case
Fixes #538
32 lines
859 B
CMake
32 lines
859 B
CMake
# - Try to find libdl
|
|
# Once done this will define
|
|
#
|
|
# LIBDL_FOUND - system has libdl
|
|
# LIBDL_INCLUDE_DIRS - the libdl include directory
|
|
# LIBDL_LIBRARIES - Link these to use libdl
|
|
# LIBDL_NEEDS_UNDERSCORE - If extern "C" symbols are prefixed (BSD/Apple)
|
|
#
|
|
|
|
find_path (LIBDL_INCLUDE_DIRS NAMES dlfcn.h)
|
|
find_library (LIBDL_LIBRARIES NAMES dl)
|
|
include (FindPackageHandleStandardArgs)
|
|
|
|
FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibDL DEFAULT_MSG
|
|
LIBDL_LIBRARIES
|
|
LIBDL_INCLUDE_DIRS)
|
|
|
|
set(CMAKE_REQUIRED_LIBRARIES dl)
|
|
include(CheckCSourceRuns)
|
|
CHECK_C_SOURCE_RUNS("#include <dlfcn.h>
|
|
#include <stdlib.h>
|
|
void testfunc() {}
|
|
int main() {
|
|
testfunc();
|
|
if (dlsym(0, \"_testfunc\") != (void*)0) {
|
|
return EXIT_SUCCESS;
|
|
} else {
|
|
return EXIT_FAILURE;
|
|
}
|
|
}" LIBDL_NEEDS_UNDERSCORE)
|
|
|
|
mark_as_advanced(LIBDL_INCLUDE_DIRS LIBDL_LIBRARIES LIBDL_NEEDS_UNDERSCORE) |