2012-04-06 15:01:58 +00:00
|
|
|
cmake_minimum_required(VERSION 2.8)
|
|
|
|
project(qtkeychain)
|
|
|
|
|
2012-05-20 12:13:40 +00:00
|
|
|
###
|
|
|
|
|
2013-01-16 17:53:49 +00:00
|
|
|
set(QTKEYCHAIN_VERSION 0.1.0)
|
2012-05-20 12:13:40 +00:00
|
|
|
set(QTKEYCHAIN_SOVERSION 0)
|
|
|
|
|
|
|
|
###
|
|
|
|
|
2012-05-02 00:34:44 +00:00
|
|
|
set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH}" "${PROJECT_SOURCE_DIR}/cmake/Modules")
|
|
|
|
include(GNUInstallDirs)
|
|
|
|
|
2012-12-23 20:55:40 +00:00
|
|
|
# try Qt5 first, and prefer that if found
|
|
|
|
find_package(Qt5Core QUIET)
|
|
|
|
if (Qt5Core_FOUND)
|
|
|
|
if(UNIX AND NOT APPLE)
|
|
|
|
find_package(Qt5DBus REQUIRED)
|
|
|
|
include_directories(${Qt5DBus_INCLUDE_DIRS})
|
|
|
|
set(QTDBUS_LIBRARIES ${Qt5DBus_LIBRARIES})
|
|
|
|
macro(qt_add_dbus_interface)
|
|
|
|
qt5_add_dbus_interface(${ARGN})
|
|
|
|
endmacro()
|
|
|
|
endif()
|
|
|
|
macro(qt_wrap_cpp)
|
|
|
|
qt5_wrap_cpp(${ARGN})
|
|
|
|
endmacro()
|
|
|
|
|
|
|
|
set(QTCORE_LIBRARIES ${Qt5Core_LIBRARIES})
|
|
|
|
include_directories(${Qt5Core_INCLUDE_DIRS})
|
|
|
|
|
|
|
|
if (Qt5_POSITION_INDEPENDENT_CODE)
|
|
|
|
if (CMAKE_VERSION VERSION_LESS 2.8.9) # TODO remove once we increase the cmake requirement
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
|
|
|
|
else()
|
|
|
|
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
|
|
|
endif()
|
|
|
|
endif()
|
2012-05-07 16:21:22 +00:00
|
|
|
else()
|
2012-12-23 20:55:40 +00:00
|
|
|
if(UNIX AND NOT APPLE)
|
|
|
|
find_package(Qt4 COMPONENTS QtCore QtDBus REQUIRED)
|
2013-01-23 09:27:03 +00:00
|
|
|
set(QTDBUS_LIBRARIES ${QT_QTDBUS_LIBRARY})
|
2012-12-23 20:55:40 +00:00
|
|
|
macro(qt_add_dbus_interface)
|
|
|
|
qt4_add_dbus_interface(${ARGN})
|
|
|
|
endmacro()
|
|
|
|
else()
|
|
|
|
find_package(Qt4 COMPONENTS QtCore REQUIRED)
|
|
|
|
endif()
|
|
|
|
include_directories(${QT_INCLUDES})
|
|
|
|
set(QTCORE_LIBRARIES ${QT_QTCORE_LIBRARY})
|
2013-01-23 09:27:03 +00:00
|
|
|
macro(qt_wrap_cpp)
|
|
|
|
qt4_wrap_cpp(${ARGN})
|
|
|
|
endmacro()
|
2012-05-07 16:21:22 +00:00
|
|
|
endif()
|
|
|
|
|
2012-04-06 15:01:58 +00:00
|
|
|
|
2012-12-23 20:55:40 +00:00
|
|
|
include_directories(${CMAKE_CURRENT_BINARY_DIR})
|
|
|
|
|
|
|
|
list(APPEND qtkeychain_LIBRARIES ${QTCORE_LIBRARIES})
|
2012-04-06 15:01:58 +00:00
|
|
|
set(qtkeychain_SOURCES
|
|
|
|
keychain.cpp
|
|
|
|
)
|
|
|
|
|
2012-04-30 13:03:36 +00:00
|
|
|
|
2012-04-06 15:01:58 +00:00
|
|
|
if(WIN32)
|
|
|
|
list(APPEND qtkeychain_SOURCES keychain_win.cpp)
|
2012-04-30 13:03:36 +00:00
|
|
|
list(APPEND qtkeychain_LIBRARIES crypt32)
|
2012-05-05 06:54:06 +00:00
|
|
|
#FIXME: mingw bug; otherwise getting undefined refs to RtlSecureZeroMemory there
|
|
|
|
if(MINGW)
|
|
|
|
add_definitions( -O2 )
|
|
|
|
endif()
|
2012-04-06 15:01:58 +00:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if(APPLE)
|
|
|
|
list(APPEND qtkeychain_SOURCES keychain_mac.cpp)
|
2012-04-30 13:03:36 +00:00
|
|
|
|
|
|
|
find_library(COREFOUNDATION_LIBRARY CoreFoundation)
|
|
|
|
list(APPEND qtkeychain_LIBRARIES ${COREFOUNDATION_LIBRARY})
|
|
|
|
|
|
|
|
find_library(SECURITY_LIBRARY Security)
|
|
|
|
list(APPEND qtkeychain_LIBRARIES ${SECURITY_LIBRARY})
|
2012-04-06 15:01:58 +00:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if(UNIX AND NOT APPLE)
|
|
|
|
list(APPEND qtkeychain_SOURCES keychain_dbus.cpp)
|
2012-12-23 20:55:40 +00:00
|
|
|
qt_add_dbus_interface(qtkeychain_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/org.kde.KWallet.xml kwallet_interface KWalletInterface)
|
|
|
|
list(APPEND qtkeychain_LIBRARIES ${QTDBUS_LIBRARIES})
|
2012-04-06 15:01:58 +00:00
|
|
|
endif()
|
|
|
|
|
2012-12-23 20:55:40 +00:00
|
|
|
QT_WRAP_CPP(qtkeychain_MOC_OUTFILES keychain.h keychain_p.h)
|
2012-05-05 08:37:48 +00:00
|
|
|
|
2012-04-06 15:01:58 +00:00
|
|
|
if(NOT QTKEYCHAIN_STATIC)
|
2012-05-05 08:37:48 +00:00
|
|
|
add_library(qtkeychain SHARED ${qtkeychain_SOURCES} ${qtkeychain_MOC_OUTFILES})
|
2012-04-06 15:01:58 +00:00
|
|
|
set_target_properties(qtkeychain PROPERTIES COMPILE_DEFINITIONS QKEYCHAIN_BUILD_QKEYCHAIN_LIB)
|
2012-05-01 23:55:31 +00:00
|
|
|
target_link_libraries(qtkeychain ${qtkeychain_LIBRARIES})
|
2012-04-06 15:01:58 +00:00
|
|
|
else()
|
2012-05-05 08:37:48 +00:00
|
|
|
add_library(qtkeychain STATIC ${qtkeychain_SOURCES} ${qtkeychain_MOC_OUTFILES})
|
2012-05-01 23:55:31 +00:00
|
|
|
set_target_properties(qtkeychain PROPERTIES COMPILE_DEFINITIONS QKEYCHAIN_STATICLIB)
|
|
|
|
endif()
|
2012-05-02 00:34:44 +00:00
|
|
|
|
|
|
|
set_target_properties(qtkeychain PROPERTIES
|
2012-05-20 12:13:40 +00:00
|
|
|
VERSION ${QTKEYCHAIN_VERSION}
|
|
|
|
SOVERSION ${QTKEYCHAIN_SOVERSION}
|
2012-05-02 00:34:44 +00:00
|
|
|
)
|
|
|
|
|
2012-05-20 12:13:40 +00:00
|
|
|
install(FILES keychain.h qkeychain_export.h
|
2012-05-02 00:34:44 +00:00
|
|
|
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/qtkeychain/
|
|
|
|
)
|
|
|
|
|
|
|
|
install(TARGETS qtkeychain
|
2012-05-20 12:13:40 +00:00
|
|
|
EXPORT QtKeychainLibraryDepends
|
2012-05-02 00:34:44 +00:00
|
|
|
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
|
|
|
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
|
|
|
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
|
|
|
)
|
2012-05-07 14:44:55 +00:00
|
|
|
|
|
|
|
add_executable( testclient testclient.cpp )
|
|
|
|
target_link_libraries( testclient qtkeychain)
|
2012-05-20 12:13:40 +00:00
|
|
|
|
|
|
|
|
|
|
|
###
|
|
|
|
### CMake config file
|
|
|
|
###
|
|
|
|
|
|
|
|
export(TARGETS qtkeychain FILE "${PROJECT_BINARY_DIR}/QtKeychainLibraryDepends.cmake")
|
|
|
|
export(PACKAGE QtKeychain)
|
|
|
|
|
|
|
|
configure_file(QtKeychainBuildTreeSettings.cmake.in
|
|
|
|
"${PROJECT_BINARY_DIR}/QtKeychainBuildTreeSettings.cmake" @ONLY)
|
|
|
|
configure_file(QtKeychainConfig.cmake.in
|
|
|
|
"${PROJECT_BINARY_DIR}/QtKeychainConfig.cmake" @ONLY)
|
|
|
|
configure_file(QtKeychainConfigVersion.cmake.in
|
|
|
|
"${PROJECT_BINARY_DIR}/QtKeychainConfigVersion.cmake" @ONLY)
|
|
|
|
|
|
|
|
install(EXPORT QtKeychainLibraryDepends
|
|
|
|
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/QtKeychain"
|
|
|
|
)
|
|
|
|
|
|
|
|
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/QtKeychainConfig.cmake
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/QtKeychainConfigVersion.cmake
|
|
|
|
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/QtKeychain
|
|
|
|
)
|
2012-12-23 20:55:40 +00:00
|
|
|
|