Skip to content

Commit

Permalink
CMake files updated:
Browse files Browse the repository at this point in the history
Reduced global definitions count;
USE_DBUS option moved to Linux like systems section;
Fixed include regular expression;
Fixed wrong options compilation on Linux.
  • Loading branch information
Vitozz committed May 16, 2024
1 parent e18062a commit 870e533
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 24 deletions.
31 changes: 7 additions & 24 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules" )
include(psi-cmake-functions)
include(policyRules)

# Define LINUX on Linux like as WIN32 on Windows and APPLE on macOS
# Define LINUX on Linux like and BSD as WIN32 on Windows and APPLE on macOS
if(UNIX AND (NOT (APPLE OR HAIKU) AND NOT CYGWIN))
set(LINUX ON)
endif()
Expand All @@ -38,7 +38,7 @@ set(SBM_LIST
)
foreach(submodule ${SBM_LIST})
if(NOT EXISTS "${submodule}")
message(FATAL_ERROR "Psi ${submodule} submodule not found.\nPlease run:\n====\ncd ${PROJECT_SOURCE_DIR}\ngit submodule init\ngit submodule update\n====\nbefore run cmake again")
message(FATAL_ERROR "Psi ${submodule} submodule not found.\nPlease run:\n====\ncd ${PROJECT_SOURCE_DIR}\ngit submodule update --init --recursive\n====\nbefore run cmake again")
endif()
endforeach()

Expand Down Expand Up @@ -67,7 +67,6 @@ option( USE_ENCHANT "Build psi with enchant spellcheck" OFF )
option( USE_ASPELL "Build psi with aspell spellcheck" OFF )
option( USE_CCACHE "Use ccache utility if found" ON )
option( USE_CRASH "Enable builtin sigsegv handling" OFF )
option( USE_DBUS "Enable DBUS support" ON )
option( USE_KEYCHAIN "Enable QtKeychain support" ON )
option( ONLY_BINARY "Build and install only binary file" OFF )
option( ONLY_PLUGINS "Build psi plugins only" OFF )
Expand All @@ -94,6 +93,7 @@ option( USE_MXE "Use MXE (cross-compilation build environment for MS Windows)" $

# Other systems
if(LINUX)
option( USE_DBUS "Enable DBUS support" ON )
option( USE_X11 "Enable X11 features support" ON )
option( USE_XSS "Enable Xscreensaver support" ON )
option( LIMIT_X11_USAGE "Disable usage of X11 features which may crash program" OFF )
Expand Down Expand Up @@ -124,17 +124,10 @@ set(IS_WEBENGINE OFF CACHE INTERNAL "Use webengine. Internal variable")
string(TOLOWER "${CHAT_TYPE}" LCHAT_TYPE)

if("${LCHAT_TYPE}" STREQUAL "webkit")
add_definitions(
-DWEBKIT
)
set(IS_WEBKIT ON)
message(STATUS "Chatlog type - QtWebKit")
elseif("${LCHAT_TYPE}" STREQUAL "webengine")
set(IS_WEBENGINE ON)
add_definitions(
-DWEBKIT
-DWEBENGINE=1
)
message(STATUS "Chatlog type - QtWebEngine")
else()
set(IS_WEBKIT OFF)
Expand All @@ -145,15 +138,12 @@ endif()
message(STATUS "System name - ${CMAKE_SYSTEM_NAME}")

if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug" OR ("${CMAKE_BUILD_TYPE}" STREQUAL "RelWithDebInfo"))
set(ISDEBUG ON)
set(ISDEBUG ON CACHE INTERNAL "Debug on RelWithDebInfo build type enabled")
option(PLUGIN_INSTALL_PATH_DEBUG "Add -DPLUGIN_INSTALL_PATH_DEBUG definition" OFF)
option(CHATVIEW_CORRECTION_DEBUG "Add -DCORRECTION_DEBUG definition" OFF)
if(PLUGIN_INSTALL_PATH_DEBUG)
add_definitions(-DPLUGIN_INSTALL_PATH_DEBUG)
endif()
if(CHATVIEW_CORRECTION_DEBUG)
add_definitions(-DCORRECTION_DEBUG)
endif()
if(WIN32)
option( NO_DEBUG_OPTIMIZATION "Disable optimization for debug builds" OFF )
endif()
Expand All @@ -178,27 +168,20 @@ elseif(NOT ENABLE_PLUGINS AND BUILD_PSIMEDIA)
message(FATAL_ERROR "BUILD_PSIMEDIA flag not works without ENABLE_PLUGINS flag.\nPlease enable ENABLE_PLUGINS flag or disable BUILD_PSIMEDIA flag")
endif()

if(USE_CRASH)
add_definitions(-DUSE_CRASH)
endif()

if(WIN32 OR USE_MXE)
set(BUNDLED_IRIS_ALL ON)
endif()

# For GNU/Linux and *BSD systems:
if(UNIX AND NOT (APPLE OR HAIKU))
if(UNIX AND (NOT (APPLE OR HAIKU) AND NOT CYGWIN))
if(USE_X11)
add_definitions( -DHAVE_X11 )
message(STATUS "X11 features support - ENABLED")
if(LIMIT_X11_USAGE)
add_definitions( -DLIMIT_X11_USAGE )
message(STATUS "Unsafe X11 features support - DISABLED")
set(USE_XSS OFF)
message(STATUS "Xscreensaver support - DISABLED")
endif()
if(USE_XSS)
add_definitions( -DHAVE_XSS )
message(STATUS "Xscreensaver support - ENABLED")
endif()
endif()
Expand All @@ -223,8 +206,8 @@ if(PROJECT_OS_NETBSD)
endif()

# Qt dependencies make building very slow
# Track only .h files
include_regular_expression("^.*\\.h$")
# Track only .h and .hpp files
include_regular_expression("^.*\\.h$|^.*\\.hpp$")

# Put executable in build root dir
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/psi" )
Expand Down
24 changes: 24 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,7 @@ if(APPLE)
target_link_libraries(${PROJECT_NAME} CocoaUtilities)
endif()

#Privare Psi project defenitions
if(LINUX)
if(NOT VERBOSED_NAME)
set(VERBOSED_NAME ${PROJECT_NAME})
Expand All @@ -494,12 +495,35 @@ if(LINUX)
APP_PREFIX=${CMAKE_INSTALL_PREFIX}
APP_BIN_NAME=${VERBOSED_NAME}
)
#Set compile definions for options static library
target_compile_definitions(options PRIVATE
HAVE_FREEDESKTOP
APP_BIN_NAME=${VERBOSED_NAME}
)
endif()

#TaskbarNotifier definition
if(WIN32 OR USE_DBUS)
target_compile_definitions(${PROJECT_NAME} PRIVATE USE_TASKBARNOTIFIER)
endif()
if(USE_CRASH)
target_compile_definitions(${PROJECT_NAME} PRIVATE USE_CRASH)
endif()
if(LINUX AND USE_X11)
target_compile_definitions(${PROJECT_NAME} PRIVATE HAVE_X11)
if(LIMIT_X11_USAGE)
target_compile_definitions(${PROJECT_NAME} PRIVATE LIMIT_X11_USAGE)
endif()
endif()
if(IS_WEBKIT OR IS_WEBENGINE)
target_compile_definitions(${PROJECT_NAME} PRIVATE WEBKIT)
if(IS_WEBENGINE)
target_compile_definitions(${PROJECT_NAME} PRIVATE WEBENGINE)
endif()
endif()
if(ISDEBUG AND CHATVIEW_CORRECTION_DEBUG)
target_compile_definitions(${PROJECT_NAME} PRIVATE CORRECTION_DEBUG)
endif()

#Pre-install section
set(OTHER_FILES
Expand Down
9 changes: 9 additions & 0 deletions src/tools/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -154,3 +154,12 @@ target_include_directories(tools PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/iconset
${CMAKE_CURRENT_SOURCE_DIR}/tunecontroller
)
if(LINUX AND USE_X11)
target_compile_definitions(tools PRIVATE HAVE_X11)
if(LIMIT_X11_USAGE)
target_compile_definitions(tools PRIVATE LIMIT_X11_USAGE)
endif()
if(USE_XSS)
target_compile_definitions(tools PRIVATE HAVE_XSS)
endif()
endif()
9 changes: 9 additions & 0 deletions src/widgets/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,12 @@ qt_wrap_ui(UI_FORMS ${FORMS})
add_library(widgets STATIC ${SOURCES} ${HEADERS} ${UI_FORMS})
target_link_libraries(widgets ${QT_LIBRARIES} ${iris_LIB} tools)
target_include_directories(widgets PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_LIST_DIR})
if(IS_WEBKIT OR IS_WEBENGINE)
target_compile_definitions(widgets PRIVATE WEBKIT)
if(IS_WEBENGINE)
target_compile_definitions(widgets PRIVATE WEBENGINE)
endif()
endif()
if(LINUX AND USE_X11)
target_compile_definitions(widgets PRIVATE HAVE_X11)
endif()

0 comments on commit 870e533

Please sign in to comment.