keepassxc/CMakeLists.txt

101 lines
3.9 KiB
CMake
Raw Normal View History

2010-08-07 09:10:44 -04:00
# Copyright (C) 2010 Felix Geyer <debfx@fobos.de>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 or (at your option)
# version 3 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
2010-08-13 12:08:06 -04:00
project(KeePassX)
2010-08-07 09:10:44 -04:00
cmake_minimum_required(VERSION 2.6.0)
set( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake )
2010-08-13 12:08:06 -04:00
option(WITH_TESTS "Enable building of unit tests" ON)
2011-12-26 13:18:21 -05:00
option(WITH_GUI_TESTS "Enable building of GUI tests" OFF)
2010-08-07 09:10:44 -04:00
2010-08-13 12:08:06 -04:00
set( KEEPASSX_VERSION "0.9.0" )
add_definitions(-DQT_NO_KEYWORDS -DQT_NO_EXCEPTIONS -DQT_NO_STL -DQT_STRICT_ITERATORS)
2010-09-19 10:57:40 -04:00
if(CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ansi -fno-common -fno-exceptions -fno-rtti")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wundef -Wold-style-cast -Wnon-virtual-dtor -Wcast-align")
2012-04-05 12:30:29 -04:00
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wpointer-arith -Wformat=2 -Werror=format-security -Woverloaded-virtual -Wno-long-long")
2011-12-22 10:25:50 -05:00
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fstack-protector --param=ssp-buffer-size=4 -D_FORTIFY_SOURCE=2")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -ansi -fno-common")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wundef -Wcast-align -Wchar-subscripts -Wpointer-arith")
2012-04-05 12:30:29 -04:00
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wwrite-strings -Wformat=2 -Werror=format-security -Werror=implicit-function-declaration")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wmissing-format-attribute -Wno-long-long")
2011-12-22 10:25:50 -05:00
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fstack-protector --param=ssp-buffer-size=4 -D_FORTIFY_SOURCE=2")
2011-11-11 19:48:49 -05:00
if( CMAKE_SYSTEM_NAME STREQUAL "Linux" )
2011-12-22 10:25:50 -05:00
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--no-add-needed -Wl,--as-needed -Wl,--no-undefined")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-z,relro")
2011-11-11 19:48:49 -05:00
endif( CMAKE_SYSTEM_NAME STREQUAL "Linux" )
2010-09-19 10:57:40 -04:00
endif(CMAKE_COMPILER_IS_GNUCXX)
2010-08-07 09:10:44 -04:00
if( APPLE OR MINGW )
set( PROGNAME KeePassX )
else( APPLE OR MINGW )
set( PROGNAME keepassx )
endif( APPLE OR MINGW )
if(MINGW)
set(BIN_INSTALL_DIR "")
set(DATA_INSTALL_DIR "share")
elseif(APPLE)
set(BIN_INSTALL_DIR "")
set(DATA_INSTALL_DIR "Contents/Resources")
else(MINGW)
set(BIN_INSTALL_DIR "bin")
set(DATA_INSTALL_DIR "share/keepassx")
endif( MINGW )
2010-08-13 12:08:06 -04:00
if( WITH_TESTS )
enable_testing()
endif( WITH_TESTS )
find_package(Qt4 4.6.0 REQUIRED QtCore QtGui QtTest)
add_definitions(${QT_DEFINITIONS} -DQT_CORE_LIB -DQT_GUI_LIB)
set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS_DEBUG QT_DEBUG)
set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS_RELEASE QT_NO_DEBUG)
set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS_RELWITHDEBINFO QT_NO_DEBUG)
set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS_MINSIZEREL QT_NO_DEBUG)
2010-08-07 09:10:44 -04:00
2011-11-12 06:00:49 -05:00
find_package(Gcrypt REQUIRED)
find_package(ZLIB REQUIRED)
include(CheckCXXSourceCompiles)
check_cxx_source_compiles("
#include <zlib.h>
#if !defined(ZLIB_VERNUM) || (ZLIB_VERNUM < 0x1200)
#error zlib 1.2.x or higher is required to use the gzip format
#endif
int main() { return 0; }" ZLIB_SUPPORTS_GZIP)
if(NOT ZLIB_SUPPORTS_GZIP)
message(FATAL_ERROR "zlib 1.2.x or higher is required to use the gzip format")
endif(NOT ZLIB_SUPPORTS_GZIP)
include_directories(${QT_INCLUDE_DIR} ${GCRYPT_INCLUDE_DIR} ${ZLIB_INCLUDE_DIR})
2010-08-07 09:10:44 -04:00
add_subdirectory(src)
add_subdirectory(share)
add_subdirectory(utils)
2010-08-13 12:08:06 -04:00
if( WITH_TESTS )
add_subdirectory(tests)
endif( WITH_TESTS )