Skip to content

Commit

Permalink
Do not explicitly set plugin compile option
Browse files Browse the repository at this point in the history
Rather have public compile options in libalbert.
The variable is probably not available in the install tree anyway.
  • Loading branch information
ManuelSchneid3r committed Dec 6, 2024
1 parent a5224c3 commit 91df9e8
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 36 deletions.
69 changes: 35 additions & 34 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,34 +19,6 @@ set(PROJECT_DISPLAY_NAME "Albert")
# Local cmake modules (also CMake uses this in a pretty obscure way, e.g. for the plist)
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")

set(ALBERT_COMPILE_OPTIONS
#-Werror
-Wall
-Wextra
-Wpedantic

# warnings that should be errors
-Werror=return-type # silently buils but crashes at runtime
-Werror=float-conversion # Implicit cast may loose precision (e.g. match scores)

# -Wconversion
# -Weffc++
-Winline
-Wmissing-field-initializers
-Wshadow
-Wstrict-aliasing

# Use this from time to time
# -Weverything
# -Wdocumentation
# -Wno-c++98-compat
# -Wno-c++20-compat
# -Wno-c++98-compat-pedantic

# ??
# -Wl,-undefined
)

# Put the binaries in dedicated toplevel directories
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
Expand Down Expand Up @@ -74,7 +46,6 @@ set(TARGET_LIB lib${PROJECT_NAME})
set(LIB_PUBLIC_HEADER
${PROJECT_BINARY_DIR}/include/albert/config.h # generated
${PROJECT_BINARY_DIR}/include/albert/export.h # generated

include/albert/action.h
include/albert/backgroundexecutor.h
include/albert/extension.h
Expand Down Expand Up @@ -246,8 +217,6 @@ generate_export_header(${TARGET_LIB}

target_precompile_headers(${TARGET_LIB} PRIVATE ${LIB_PUBLIC_HEADER})

target_compile_options(${TARGET_LIB} PRIVATE ${ALBERT_COMPILE_OPTIONS})

target_include_directories(${TARGET_LIB}
PUBLIC
"$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/include/>"
Expand Down Expand Up @@ -333,6 +302,37 @@ set_target_properties(${TARGET_LIB} PROPERTIES
AUTORCC ON
)

target_compile_options(${TARGET_LIB}
PUBLIC
#-Werror
-Wall
-Wextra
-Wpedantic

# warnings that should be errors
-Werror=return-type # silently buils but crashes at runtime
-Werror=float-conversion # Implicit cast may loose precision (e.g. match scores)

# -Wconversion
# -Weffc++
-Winline
-Wmissing-field-initializers
-Wshadow
-Wstrict-aliasing
-Winvalid-pch

# Use this from time to time
# -Weverything
# -Wdocumentation
# -Wno-c++98-compat
# -Wno-c++20-compat
# -Wno-c++98-compat-pedantic

# ??
# -Wl,-undefined
)


### Internationalization

file(GLOB TS_FILES i18n/*.ts)
Expand All @@ -358,6 +358,7 @@ qt_add_translations(
# For convenience, QtCreator does not show the umbrella target
add_custom_target(global_lupdate DEPENDS update_translations)


### Export/Install

include(CMakePackageConfigHelpers)
Expand All @@ -375,7 +376,7 @@ set(INSTALL_CONFIGDIR "${CMAKE_INSTALL_LIBDIR}/cmake/Albert")
# https://cmake.org/cmake/help/latest/command/install.html#targets
install(
TARGETS ${TARGET_LIB}
EXPORT ${LIB_EXPORT_NAME} # just an association
EXPORT ${LIB_EXPORT_NAME} # association for install(EXPORT …) and export(EXPORT …)
FRAMEWORK DESTINATION .
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
Expand All @@ -386,7 +387,7 @@ install(
# https://cmake.org/cmake/help/latest/command/install.html#export
# By default the generated file will be called <export-name>.cmake
install(
EXPORT ${LIB_EXPORT_NAME}
EXPORT ${LIB_EXPORT_NAME} # association from above
NAMESPACE ${PROJECT_NAME}::
DESTINATION ${INSTALL_CONFIGDIR}
)
Expand All @@ -395,7 +396,7 @@ install(
# https://cmake.org/cmake/help/latest/command/export.html#exporting-targets-matching-install-export
# Seems like a shorthand for export(TARGETS)
export(
EXPORT ${LIB_EXPORT_NAME}
EXPORT ${LIB_EXPORT_NAME} # association from above
NAMESPACE ${PROJECT_NAME}::
FILE "${PROJECT_BINARY_DIR}/${LIB_TARGETS_FILE}"
)
Expand Down
3 changes: 1 addition & 2 deletions cmake/albert-macros.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ macro(_albert_plugin_add_target)
CXX_STANDARD_REQUIRED ON
CXX_EXTENSIONS OFF
CXX_VISIBILITY_PRESET hidden
VISIBILITY_INLINES_HIDDEN j
VISIBILITY_INLINES_HIDDEN ON
PREFIX "" # no libfoo
AUTOMOC ON
AUTOUIC ON
Expand All @@ -107,7 +107,6 @@ macro(_albert_plugin_add_target)
set_property(TARGET ${PROJECT_NAME}
APPEND PROPERTY AUTOMOC_MACRO_NAMES "ALBERT_PLUGIN")

target_compile_options(${PROJECT_NAME} PRIVATE ${ALBERT_COMPILE_OPTIONS})

target_include_directories(${PROJECT_NAME} PRIVATE ${PROJECT_BINARY_DIR})
if (DEFINED ARG_INCLUDE)
Expand Down

0 comments on commit 91df9e8

Please sign in to comment.