Stop stuttering in CMake scripts

This commit is contained in:
Přemysl Eric Janouch 2021-10-29 04:56:56 +02:00
parent ed6d34159e
commit dd48af42eb
Signed by: p
GPG Key ID: A0420B94F92B9493
2 changed files with 31 additions and 31 deletions

View File

@ -23,7 +23,7 @@ if (WIN32)
if (CMAKE_CROSSCOMPILING) if (CMAKE_CROSSCOMPILING)
list (APPEND CMAKE_FIND_ROOT_PATH ${WIN32_DEPENDS_PATH}) list (APPEND CMAKE_FIND_ROOT_PATH ${WIN32_DEPENDS_PATH})
endif (CMAKE_CROSSCOMPILING) endif ()
set (PKG_CONFIG_USE_CMAKE_PREFIX_PATH FALSE) set (PKG_CONFIG_USE_CMAKE_PREFIX_PATH FALSE)
# Seems like there is a regression setting this to two paths in one, # Seems like there is a regression setting this to two paths in one,
@ -35,7 +35,7 @@ if (WIN32)
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}) WORKING_DIRECTORY ${PROJECT_SOURCE_DIR})
add_custom_target (win32-depends-clean COMMAND ${CMAKE_COMMAND} -E add_custom_target (win32-depends-clean COMMAND ${CMAKE_COMMAND} -E
remove_directory ${WIN32_DEPENDS_PATH}) remove_directory ${WIN32_DEPENDS_PATH})
endif (WIN32) endif ()
# Generate icons # Generate icons
find_program (CONVERT_EXECUTABLE convert) find_program (CONVERT_EXECUTABLE convert)
@ -62,14 +62,14 @@ if (CONVERT_EXECUTABLE AND NOT WIN32)
DEPENDS ${icon_svg} VERBATIM) DEPENDS ${icon_svg} VERBATIM)
set_source_files_properties (${icon_symbolic} set_source_files_properties (${icon_symbolic}
PROPERTIES SYMBOLIC TRUE) PROPERTIES SYMBOLIC TRUE)
endforeach (icon_size) endforeach ()
set (icon_ico ${PROJECT_SOURCE_DIR}/share/logdiag.ico) set (icon_ico ${PROJECT_SOURCE_DIR}/share/logdiag.ico)
add_custom_target (${PROJECT_NAME}_icons add_custom_target (${PROJECT_NAME}_icons
DEPENDS ${icon_symbolic_list} DEPENDS ${icon_symbolic_list}
COMMAND ${CONVERT_EXECUTABLE} ${icon_png_list} ${icon_ico} COMMAND ${CONVERT_EXECUTABLE} ${icon_png_list} ${icon_ico}
COMMENT "Generating logdiag.ico" VERBATIM) COMMENT "Generating logdiag.ico" VERBATIM)
endif (CONVERT_EXECUTABLE AND NOT WIN32) endif ()
# Dependencies # Dependencies
find_package (PkgConfig REQUIRED) find_package (PkgConfig REQUIRED)
@ -77,17 +77,17 @@ pkg_check_modules (GTK3 REQUIRED gtk+-3.0 json-glib-1.0)
if (NOT WIN32) if (NOT WIN32)
pkg_search_module (Lua REQUIRED lua>=5.2 lua5.3 lua-5.3 lua5.2 lua-5.2) pkg_search_module (Lua REQUIRED lua>=5.2 lua5.3 lua-5.3 lua5.2 lua-5.2)
else (NOT WIN32) else ()
# For whatever reason this now seems to be required # For whatever reason this now seems to be required
set (LUA_INCLUDE_DIR "${WIN32_DEPENDS_PATH}/include") set (LUA_INCLUDE_DIR "${WIN32_DEPENDS_PATH}/include")
find_package (Lua REQUIRED) find_package (Lua REQUIRED)
if (LUA_VERSION_STRING VERSION_LESS "5.2") if (LUA_VERSION_STRING VERSION_LESS "5.2")
message (FATAL_ERROR "Lua 5.2 not found") message (FATAL_ERROR "Lua 5.2 not found")
endif (LUA_VERSION_STRING VERSION_LESS "5.2") endif ()
set (Lua_LIBRARIES ${LUA_LIBRARIES}) set (Lua_LIBRARIES ${LUA_LIBRARIES})
set (Lua_INCLUDE_DIRS ${LUA_INCLUDE_DIR}) set (Lua_INCLUDE_DIRS ${LUA_INCLUDE_DIR})
endif (NOT WIN32) endif ()
# This actually fucks up MinGW cross-compilation if omitted # This actually fucks up MinGW cross-compilation if omitted
link_directories (${GTK3_LIBRARY_DIRS}) link_directories (${GTK3_LIBRARY_DIRS})
@ -102,7 +102,7 @@ GETTEXT_CREATE_TRANSLATIONS (
foreach (file ${project_PO_FILES}) foreach (file ${project_PO_FILES})
get_filename_component (translation "${file}" NAME_WE) get_filename_component (translation "${file}" NAME_WE)
list (APPEND project_TRANSLATIONS "${translation}") list (APPEND project_TRANSLATIONS "${translation}")
endforeach (file) endforeach ()
# Project source files # Project source files
set (liblogdiag_SOURCES set (liblogdiag_SOURCES
@ -159,7 +159,7 @@ set (logdiag_HEADERS
if (WIN32) if (WIN32)
# The file isn't scanned for dependencies, but they will only rarely change # The file isn't scanned for dependencies, but they will only rarely change
list (APPEND logdiag_SOURCES share/logdiag.rc) list (APPEND logdiag_SOURCES share/logdiag.rc)
endif (WIN32) endif ()
# Generate a configure file # Generate a configure file
add_definitions (-DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_36) add_definitions (-DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_36)
@ -172,7 +172,7 @@ include_directories (${PROJECT_BINARY_DIR})
find_program (GLIB_GENMARSHAL_EXECUTABLE glib-genmarshal) find_program (GLIB_GENMARSHAL_EXECUTABLE glib-genmarshal)
if (NOT GLIB_GENMARSHAL_EXECUTABLE) if (NOT GLIB_GENMARSHAL_EXECUTABLE)
message (FATAL_ERROR "glib-genmarshal not found") message (FATAL_ERROR "glib-genmarshal not found")
endif (NOT GLIB_GENMARSHAL_EXECUTABLE) endif ()
function (glib_genmarshal base prefix) function (glib_genmarshal base prefix)
get_filename_component (base_path "${base}" PATH) get_filename_component (base_path "${base}" PATH)
@ -187,7 +187,7 @@ function (glib_genmarshal base prefix)
if (WIN32 AND "${base_path}" MATCHES "^.:[/\\\\]") if (WIN32 AND "${base_path}" MATCHES "^.:[/\\\\]")
string (SUBSTRING "${base_path}" 0 2 base_drive) string (SUBSTRING "${base_path}" 0 2 base_drive)
set (command_base "${base_drive}" && "${command_base}") set (command_base "${base_drive}" && "${command_base}")
endif (WIN32 AND "${base_path}" MATCHES "^.:[/\\\\]") endif ()
# NOTE: VERBATIM would cause problems, so it is not used here # NOTE: VERBATIM would cause problems, so it is not used here
add_custom_command (OUTPUT ${base}.c add_custom_command (OUTPUT ${base}.c
@ -200,7 +200,7 @@ function (glib_genmarshal base prefix)
DEPENDS "${base}.list" DEPENDS "${base}.list"
WORKING_DIRECTORY "${base_path}" WORKING_DIRECTORY "${base_path}"
COMMENT "Generating marshallers header file") COMMENT "Generating marshallers header file")
endfunction (glib_genmarshal) endfunction ()
glib_genmarshal (${PROJECT_SOURCE_DIR}/liblogdiag/ld-marshal glib_genmarshal (${PROJECT_SOURCE_DIR}/liblogdiag/ld-marshal
ld_marshal) ld_marshal)
@ -212,7 +212,7 @@ set (logdiag_LIBS ${GTK3_LIBRARIES} ${Lua_LIBRARIES} m)
if (WIN32) if (WIN32)
find_package (LibIntl REQUIRED) find_package (LibIntl REQUIRED)
list (APPEND logdiag_LIBS ${LIBINTL_LIBRARIES} shell32) list (APPEND logdiag_LIBS ${LIBINTL_LIBRARIES} shell32)
endif (WIN32) endif ()
# Build the library # Build the library
add_library (liblogdiag STATIC ${liblogdiag_SOURCES} ${liblogdiag_HEADERS}) add_library (liblogdiag STATIC ${liblogdiag_SOURCES} ${liblogdiag_HEADERS})
@ -231,12 +231,12 @@ if (BUILD_TESTING)
target_link_libraries (test-${name} liblogdiag ${logdiag_LIBS}) target_link_libraries (test-${name} liblogdiag ${logdiag_LIBS})
add_test (NAME test-${name} COMMAND test-${name}) add_test (NAME test-${name} COMMAND test-${name})
list (APPEND logdiag_TEST_TARGETS test-${name}) list (APPEND logdiag_TEST_TARGETS test-${name})
endforeach (name) endforeach ()
if (WIN32 AND NOT CMAKE_CROSSCOMPILING) if (WIN32 AND NOT CMAKE_CROSSCOMPILING)
set_tests_properties (${logdiag_TEST_TARGETS} set_tests_properties (${logdiag_TEST_TARGETS}
PROPERTIES ENVIRONMENT "PATH=${WIN32_DEPENDS_PATH}/bin") PROPERTIES ENVIRONMENT "PATH=${WIN32_DEPENDS_PATH}/bin")
endif () endif ()
endif (BUILD_TESTING) endif ()
# Generate documentation # Generate documentation
if (OPTION_GTKDOC) if (OPTION_GTKDOC)
@ -303,7 +303,7 @@ endif ()
find_program (GLIB_COMPILE_SCHEMAS_EXECUTABLE glib-compile-schemas) find_program (GLIB_COMPILE_SCHEMAS_EXECUTABLE glib-compile-schemas)
if (NOT GLIB_COMPILE_SCHEMAS_EXECUTABLE) if (NOT GLIB_COMPILE_SCHEMAS_EXECUTABLE)
message (FATAL_ERROR "glib-compile-schemas not found") message (FATAL_ERROR "glib-compile-schemas not found")
endif (NOT GLIB_COMPILE_SCHEMAS_EXECUTABLE) endif ()
set (GSETTINGS_DIR "${PROJECT_SOURCE_DIR}/share") set (GSETTINGS_DIR "${PROJECT_SOURCE_DIR}/share")
set (GSETTINGS_SCHEMAS "${GSETTINGS_DIR}/org.logdiag.gschema.xml") set (GSETTINGS_SCHEMAS "${GSETTINGS_DIR}/org.logdiag.gschema.xml")
@ -323,7 +323,7 @@ if (OPTION_NOINSTALL)
COMMENT "Compiling GSettings schema files" VERBATIM) COMMENT "Compiling GSettings schema files" VERBATIM)
add_custom_target (${PROJECT_NAME}_gschema ALL add_custom_target (${PROJECT_NAME}_gschema ALL
DEPENDS "${GSETTINGS_COMPILED_SCHEMA}") DEPENDS "${GSETTINGS_COMPILED_SCHEMA}")
endif (OPTION_NOINSTALL) endif ()
# Installation # Installation
if (WIN32) if (WIN32)
@ -361,11 +361,11 @@ if (WIN32)
install (DIRECTORY install (DIRECTORY
${WIN32_DEPENDS_PATH}/share/locale/${translation} ${WIN32_DEPENDS_PATH}/share/locale/${translation}
DESTINATION share/locale) DESTINATION share/locale)
endif (translation_found GREATER -1) endif ()
endforeach (locale) endforeach ()
install (SCRIPT Win32Cleanup.cmake) install (SCRIPT Win32Cleanup.cmake)
else (WIN32) else ()
install (TARGETS logdiag DESTINATION bin) install (TARGETS logdiag DESTINATION bin)
install (FILES share/logdiag.desktop DESTINATION share/applications) install (FILES share/logdiag.desktop DESTINATION share/applications)
install (FILES share/logdiag.xml DESTINATION share/mime/packages) install (FILES share/logdiag.xml DESTINATION share/mime/packages)
@ -374,7 +374,7 @@ else (WIN32)
# install (DIRECTORY "${project_DOC_DIR}/html/" # install (DIRECTORY "${project_DOC_DIR}/html/"
# DESTINATION share/gtk-doc/html/${PROJECT_NAME}) # DESTINATION share/gtk-doc/html/${PROJECT_NAME})
install (FILES LICENSE NEWS DESTINATION share/doc/${PROJECT_NAME}) install (FILES LICENSE NEWS DESTINATION share/doc/${PROJECT_NAME})
endif (WIN32) endif ()
install (DIRECTORY docs/user-guide DESTINATION share/doc/${PROJECT_NAME}) install (DIRECTORY docs/user-guide DESTINATION share/doc/${PROJECT_NAME})
install (DIRECTORY share/gui share/library DESTINATION share/${PROJECT_NAME}) install (DIRECTORY share/gui share/library DESTINATION share/${PROJECT_NAME})
@ -394,10 +394,10 @@ set (CPACK_PACKAGE_VERSION ${PROJECT_VERSION})
if (WIN32) if (WIN32)
set (CPACK_GENERATOR "NSIS;ZIP") set (CPACK_GENERATOR "NSIS;ZIP")
else (WIN32) else ()
set (CPACK_GENERATOR "TGZ;ZIP") set (CPACK_GENERATOR "TGZ;ZIP")
set (CPACK_SET_DESTDIR TRUE) set (CPACK_SET_DESTDIR TRUE)
endif (WIN32) endif ()
set (CPACK_PACKAGE_FILE_NAME set (CPACK_PACKAGE_FILE_NAME
"${PROJECT_NAME}-${PROJECT_VERSION}-${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR}") "${PROJECT_NAME}-${PROJECT_VERSION}-${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR}")

View File

@ -15,7 +15,7 @@ file (GLOB files ${working_dir}/*)
list (REMOVE_ITEM files ${pkg_dir}) list (REMOVE_ITEM files ${pkg_dir})
if (files) if (files)
file (REMOVE_RECURSE ${files}) file (REMOVE_RECURSE ${files})
endif (files) endif ()
# Packages # Packages
set (pkg_list "geany" "winlibs" "mingw_lua") set (pkg_list "geany" "winlibs" "mingw_lua")
@ -73,16 +73,16 @@ foreach (pkg_set ${pkg_list})
if (status_errno) if (status_errno)
file (REMOVE ${filename}) file (REMOVE ${filename})
message (FATAL_ERROR "Download failed: ${status_msg}") message (FATAL_ERROR "Download failed: ${status_msg}")
endif (status_errno) endif ()
elseif (pkg_md5_sum) elseif (pkg_md5_sum)
execute_process (COMMAND ${CMAKE_COMMAND} -E md5sum ${filename} execute_process (COMMAND ${CMAKE_COMMAND} -E md5sum ${filename}
OUTPUT_VARIABLE output) OUTPUT_VARIABLE output)
if (NOT output MATCHES "^${pkg_md5_sum}") if (NOT output MATCHES "^${pkg_md5_sum}")
message (FATAL_ERROR "MD5 mismatch for ${basename}") message (FATAL_ERROR "MD5 mismatch for ${basename}")
endif (NOT output MATCHES "^${pkg_md5_sum}") endif ()
endif () endif ()
endforeach (url) endforeach ()
endforeach (pkg_set) endforeach ()
# Stage 2: extract the rest of packages # Stage 2: extract the rest of packages
foreach (pkg_set ${pkg_list}) foreach (pkg_set ${pkg_list})
@ -97,8 +97,8 @@ foreach (pkg_set ${pkg_list})
if (status) if (status)
message (FATAL_ERROR "Extraction failed: ${status}") message (FATAL_ERROR "Extraction failed: ${status}")
endif () endif ()
endforeach (url) endforeach ()
endforeach (pkg_set) endforeach ()
# Stage 3: final touches # Stage 3: final touches
# We have to fix the prefix path as it is completely wrong everywhere # We have to fix the prefix path as it is completely wrong everywhere
@ -109,4 +109,4 @@ foreach (file ${files})
string (REGEX REPLACE "prefix=[^\r\n]*(.*)" "prefix=${working_dir}\\1" string (REGEX REPLACE "prefix=[^\r\n]*(.*)" "prefix=${working_dir}\\1"
file_content_fixed "${file_content}") file_content_fixed "${file_content}")
file (WRITE ${file} "${file_content_fixed}") file (WRITE ${file} "${file_content_fixed}")
endforeach (file) endforeach ()