Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: port to macOS #338

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,16 @@ else()
message(SEND_ERROR "not support Prject Version ${PROJECT_VERSION}.")
endif()

if(APPLE)
# Force use qt6 on macOS
set(QT_VERSION_MAJOR "6")
set(DTK_VERSION_MAJOR "6")

set(CMAKE_THREAD_LIBS_INIT "-lpthread")
set(CMAKE_HAVE_THREADS_LIBRARY 1)
set(CMAKE_USE_WIN32_THREADS_INIT 0)
set(CMAKE_USE_PTHREADS_INIT 1)
set(THREADS_PREFER_PTHREAD_FLAG ON)
endif()

include(dtkcore.cmake)
2 changes: 1 addition & 1 deletion dtkcore.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()

if(NOT MSVC)
if(LINUX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -Wall -Wextra")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--as-needed")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--as-needed -pie")
Expand Down
82 changes: 28 additions & 54 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@ set(CMAKE_AUTORCC ON)
set (DSG_PREFIX_PATH "${CMAKE_INSTALL_PREFIX}" CACHE STRING "PREFIX of DSG_DATA_DIRS")
add_definitions(-DPREFIX="${DSG_PREFIX_PATH}")
add_definitions(-DLIBDTKCORE_LIBRARY)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core DBus Xml)
find_package(PkgConfig REQUIRED)
if(LINUX)
find_package(PkgConfig REQUIRED)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS DBus)
if("${QT_VERSION_MAJOR}" STREQUAL "5")
pkg_check_modules(QGSettings REQUIRED IMPORTED_TARGET gsettings-qt) #Dtk6 removed.
endif()
Expand All @@ -21,11 +20,11 @@ if(LINUX)
pkg_check_modules(Systemd REQUIRED IMPORTED_TARGET libsystemd)
endif()
endif()
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Xml)

# start text encoding
find_package(ICU REQUIRED COMPONENTS uc)
pkg_check_modules(uchardet REQUIRED uchardet)
find_package(Iconv REQUIRED)
pkg_check_modules(uchardet REQUIRED IMPORTED_TARGET uchardet)
# end text encoding

# start base
Expand Down Expand Up @@ -53,27 +52,30 @@ include(util/util.cmake)
#GLOB
include(glob.cmake)
#endGLOG

add_library(${LIB_NAME} SHARED
${base_SRCS}
${dci_SRCS}
${filesystem_SRCS}
${log_SRCS}
${settings_SRC}
${utils_SRC}
${glob_SRC}
)
target_link_libraries(
${LIB_NAME} PUBLIC
Qt${QT_VERSION_MAJOR}::Core
Qt${QT_VERSION_MAJOR}::DBus
Qt${QT_VERSION_MAJOR}::Xml
)
target_link_libraries(${LIB_NAME} PRIVATE
ICU::uc
Qt${QT_VERSION_MAJOR}::CorePrivate
PkgConfig::uchardet
Iconv
)

if(LINUX)
add_library(${LIB_NAME} SHARED
${base_SRCS}
${dci_SRCS}
${filesystem_SRCS}
${log_SRCS}
${settings_SRC}
${utils_SRC}
${glob_SRC}
)
target_link_libraries(
${LIB_NAME} PUBLIC
Qt${QT_VERSION_MAJOR}::Core
Qt${QT_VERSION_MAJOR}::DBus
Qt${QT_VERSION_MAJOR}::Xml
)
target_link_libraries(${LIB_NAME} PRIVATE
ICU::uc
Qt${QT_VERSION_MAJOR}::CorePrivate
uchardet
)
if("${QT_VERSION_MAJOR}" STREQUAL "5")
target_link_libraries(${LIB_NAME} PRIVATE
PkgConfig::QGSettings
Expand All @@ -85,41 +87,13 @@ if(LINUX)
)
add_definitions(-DBUILD_WITH_SYSTEMD)
endif()

else()
add_library(${LIB_NAME} SHARED
${base_SRCS}
${dci_SRCS}
${filesystem_SRCS}
${log_SRCS}
${settings_SRC}
${utils_SRC}
${glob_SRC}
)
target_link_libraries(
${LIB_NAME} PUBLIC
Qt${QT_VERSION_MAJOR}::Core
Qt${QT_VERSION_MAJOR}::Xml
)
target_link_libraries(${LIB_NAME} PRIVATE
ICU::uc
Qt${QT_VERSION_MAJOR}::CorePrivate
uchardet
)
if("${QT_VERSION_MAJOR}" STREQUAL "5")
target_link_libraries(${LIB_NAME} PRIVATE
PkgConfig::QGSettings
)
endif()
endif()

set_target_properties(${LIB_NAME} PROPERTIES
VERSION ${CMAKE_PROJECT_VERSION}
SOVERSION ${CMAKE_PROJECT_VERSION_MAJOR}
EXPORT_NAME Core
)
target_include_directories(${LIB_NAME} PRIVATE
${uchardet_INCLUDE_DIRS}
)
target_include_directories(${LIB_NAME} PUBLIC
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include/util>
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include/dci>
Expand Down
8 changes: 2 additions & 6 deletions src/glob.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ set(OUTER_SOURCE
${CMAKE_CURRENT_LIST_DIR}/dsecurestring.cpp
${CMAKE_CURRENT_LIST_DIR}/ddesktopentry.cpp
${CMAKE_CURRENT_LIST_DIR}/dtkcore_global.cpp
${CMAKE_CURRENT_LIST_DIR}/dconfigfile.cpp
)
set(OUTER_HEADER
${CMAKE_CURRENT_LIST_DIR}/../include/global/dtkcore_global.h
Expand All @@ -15,18 +16,13 @@ set(OUTER_HEADER
${CMAKE_CURRENT_LIST_DIR}/../include/global/dlicenseinfo.h
${CMAKE_CURRENT_LIST_DIR}/../include/global/dsecurestring.h
${CMAKE_CURRENT_LIST_DIR}/../include/global/ddesktopentry.h
${CMAKE_CURRENT_LIST_DIR}/../include/global/dconfigfile.h
)

if(LINUX)
if(DEFINED D_DSG_APP_DATA_FALLBACK)
add_definitions(-DD_DSG_APP_DATA_FALLBACK="${D_DSG_APP_DATA_FALLBACK}")
endif()
list(APPEND OUTER_SOURCE
${CMAKE_CURRENT_LIST_DIR}/dconfigfile.cpp
)
list(APPEND OUTER_HEADER
${CMAKE_CURRENT_LIST_DIR}/../include/global/dconfigfile.h
)
# generic dbus interfaces
if(NOT DEFINED DTK_DISABLE_DBUS_CONFIG)
include(${CMAKE_CURRENT_LIST_DIR}/dbus/dbus.cmake)
Expand Down
6 changes: 4 additions & 2 deletions tools/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
add_subdirectory(dci)
add_subdirectory(deepin-os-release)
add_subdirectory(qdbusxml2cpp)
if(LINUX)
add_subdirectory(deepin-os-release)
add_subdirectory(qdbusxml2cpp)
endif()
add_subdirectory(settings)
add_subdirectory(ch2py)
10 changes: 7 additions & 3 deletions tools/settings/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,12 @@ find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Xml)

if(${QT_VERSION_MAJOR} STREQUAL "5")
find_package(PkgConfig REQUIRED)
pkg_check_modules(QGSettings REQUIRED IMPORTED_TARGET gsettings-qt)
if(LINUX)
find_package(PkgConfig REQUIRED)
pkg_check_modules(QGSettings REQUIRED IMPORTED_TARGET gsettings-qt)
elseif(APPLE)
find_package(PkgConfig REQUIRED)
endif()
endif()

add_executable(${BIN_NAME}
Expand All @@ -22,7 +26,7 @@ target_link_libraries(
if(${QT_VERSION_MAJOR} STREQUAL "5")
target_link_libraries(
${BIN_NAME} PRIVATE
PkgConfig::QGSettings
# PkgConfig::QGSettings
)
endif()

Expand Down