-# Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+# Copyright (c) 2011-2020 Samsung Electronics Co., Ltd. All rights reserved
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
############################# compiler flags ##################################
SET(CMAKE_C_FLAGS_PROFILING "-g -O0 -pg -Wp,-U_FORTIFY_SOURCE")
-SET(CMAKE_CXX_FLAGS_PROFILING "-g -std=c++0x -O0 -pg -Wp,-U_FORTIFY_SOURCE")
+SET(CMAKE_CXX_FLAGS_PROFILING "-g -std=c++17 -O0 -pg -Wp,-U_FORTIFY_SOURCE -Wno-deprecated-declarations")
SET(CMAKE_C_FLAGS_DEBUG "-g -O0 -ggdb -Wp,-U_FORTIFY_SOURCE")
-SET(CMAKE_CXX_FLAGS_DEBUG "-g -std=c++0x -O0 -ggdb -Wp,-U_FORTIFY_SOURCE")
+SET(CMAKE_CXX_FLAGS_DEBUG "-g -std=c++17 -O0 -ggdb -Wp,-U_FORTIFY_SOURCE -Wshadow -Wno-deprecated-declarations")
SET(CMAKE_C_FLAGS_RELEASE "-g -O2")
-SET(CMAKE_CXX_FLAGS_RELEASE "-g -std=c++0x -O2")
-SET(CMAKE_C_FLAGS_CCOV "-g -O2 --coverage")
-SET(CMAKE_CXX_FLAGS_CCOV "-g -std=c++0x -O2 --coverage")
+SET(CMAKE_CXX_FLAGS_RELEASE "-g -std=c++17 -O2 -Wshadow -Wno-deprecated-declarations")
+SET(CMAKE_C_FLAGS_COVERAGE "-g -O0 -ggdb --coverage -Wp,-U_FORTIFY_SOURCE")
+SET(CMAKE_CXX_FLAGS_COVERAGE "-g -std=c++17 -O0 -ggdb --coverage -Wp,-U_FORTIFY_SOURCE -Wno-deprecated-declarations")
-# If supported for the target machine, emit position-independent code,suitable
-# for dynamic linking and avoiding any limit on the size of the global offset
-# table. This option makes a difference on the m68k, PowerPC and SPARC.
-# (BJ: our ARM too?)
-ADD_DEFINITIONS("-fPIC")
+# Force PIE
+SET(CMAKE_POSITION_INDEPENDENT_CODE "True")
+SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pie")
# Set compiler warning flags
ADD_DEFINITIONS("-Werror") # Make all warnings into errors.
STRING(REGEX MATCH "([^.]*)" API_VERSION "${VERSION}")
ADD_DEFINITIONS("-DAPI_VERSION=\"$(API_VERSION)\"")
ADD_DEFINITIONS("-DSMACK_ENABLED")
-ADD_DEFINITIONS("-DSQLCIPHER_HAS_CODEC")
+ADD_DEFINITIONS("-DSQLITE_HAS_CODEC")
+ADD_DEFINITIONS("-DDUMP_LEGACY_DB_LIBNAME=\"${DUMP_LEGACY_DB_LIBNAME}\"")
+ADD_DEFINITIONS("-DLIB_INSTALL_DIR=\"${LIB_INSTALL_DIR}\"")
+ADD_DEFINITIONS("-DRUN_DIR=\"${RUN_DIR}\"")
+ADD_DEFINITIONS("-DSERVICE_NAME=\"${SERVICE_NAME}\"")
+ADD_DEFINITIONS("-DUSER_NAME=\"${USER_NAME}\"")
+ADD_DEFINITIONS("-DGROUP_NAME=\"${GROUP_NAME}\"")
+ADD_DEFINITIONS("-DSMACK_DOMAIN_NAME=\"${SMACK_DOMAIN_NAME}\"")
+ADD_DEFINITIONS("-DOLD_RW_DATA_DIR=\"${OLD_RW_DATA_DIR}\"")
+ADD_DEFINITIONS("-DRW_DATA_DIR=\"${RW_DATA_DIR}\"")
+ADD_DEFINITIONS("-DRO_DATA_DIR=\"${RO_DATA_DIR}\"")
+ADD_DEFINITIONS("-DETC_DIR=\"${ETC_DIR}\"")
+ADD_DEFINITIONS("-DBIN_DIR=\"${BIN_DIR}\"")
+ADD_DEFINITIONS("-DINITIAL_VALUES_DIR_RO=\"${INITIAL_VALUES_DIR_RO}\"")
+ADD_DEFINITIONS("-DINITIAL_VALUES_DIR_RW=\"${INITIAL_VALUES_DIR_RW}\"")
+ADD_DEFINITIONS("-DCA_CERTS_DIR=\"${CA_CERTS_DIR}\"")
+ADD_DEFINITIONS("-DSYSTEMD_ENV_FILE=\"${SYSTEMD_ENV_FILE}\"")
+
+SET(KEY_MANAGER_PATH ${PROJECT_SOURCE_DIR}/src/manager)
+
+IF(NOT DEFINED COVERAGE_DIR)
+ SET(COVERAGE_DIR
+ "/opt/data/ckm-coverage"
+ CACHE PATH
+ "Read-only coverage data directory")
+ENDIF(NOT DEFINED COVERAGE_DIR)
+ADD_DEFINITIONS("-DCOVERAGE_DIR=\"${COVERAGE_DIR}\"")
+
+IF (TZ_BACKEND_ENABLED)
+ ADD_DEFINITIONS("-DTZ_BACKEND_ENABLED")
+ SET(EXTRA_KM_DEPS ${EXTRA_KM_DEPS} tef-libteec)
+ SET(KM_LINK_EXTRA_DEPS km_serialization)
+ SET(TZ_BACKEND_SOURCES
+ ${KEY_MANAGER_PATH}/crypto/tz-backend/internals.cpp
+ ${KEY_MANAGER_PATH}/crypto/tz-backend/obj.cpp
+ ${KEY_MANAGER_PATH}/crypto/tz-backend/ctx.cpp
+ ${KEY_MANAGER_PATH}/crypto/tz-backend/store.cpp
+ ${KEY_MANAGER_PATH}/crypto/tz-backend/tz-context.cpp
+ ${KEY_MANAGER_PATH}/crypto/tz-backend/tz-memory.cpp
+ ${KEY_MANAGER_PATH}/crypto/tz-backend/tz-serializer.cpp
+ )
+ENDIF()
+
+IF (SE_BACKEND_ENABLED)
+ ADD_DEFINITIONS("-DSE_BACKEND_ENABLED")
+ SET(SE_BACKEND_SOURCES
+ ${KEY_MANAGER_PATH}/crypto/se-backend/internals.cpp
+ )
+ SET(EXTRA_KM_DEPS ${EXTRA_KM_DEPS} key-manager-se-backend)
+ENDIF()
+
+IF (DEFINED WATCHDOG_ENABLED)
+ MESSAGE("WATCHDOG ENABLED!")
+ ADD_DEFINITIONS("-DWATCHDOG_ENABLED")
+ ADD_DEFINITIONS("-DWATCHDOG_TIMEOUT_SEC=${WATCHDOG_TIMEOUT_SEC}")
+ ADD_DEFINITIONS("-DWATCHDOG_NOTIFY_SEC=${WATCHDOG_NOTIFY_SEC}")
+ SET(WATCHDOG_DECLARE "NotifyAccess=main")
+ SET(EXTRA_KM_DEPS ${EXTRA_KM_DEPS} argos_watchdog)
+ENDIF (DEFINED WATCHDOG_ENABLED)
IF (CMAKE_BUILD_TYPE MATCHES "DEBUG")
ADD_DEFINITIONS("-DTIZEN_DEBUG_ENABLE")
ADD_DEFINITIONS("-DBUILD_TYPE_DEBUG")
+ELSE (CMAKE_BUILD_TYPE MATCHES "DEBUG")
+ ADD_DEFINITIONS("-DNDEBUG=1")
ENDIF (CMAKE_BUILD_TYPE MATCHES "DEBUG")
-IF (DEFINED SECURITY_MDFPP_STATE_ENABLE)
- MESSAGE("SECURITY_MDFPP_STATE_ENABLE ENABLED !")
- ADD_DEFINITIONS("-DSECURITY_MDFPP_STATE_ENABLE")
-ELSE (DEFINED SECURITY_MDFPP_STATE_ENABLE)
- MESSAGE("SECURITY_MDFPP_STATE_ENABLE DISABLED !")
-ENDIF (DEFINED SECURITY_MDFPP_STATE_ENABLE)
-
SET(TARGET_KEY_MANAGER "key-manager")
SET(TARGET_KEY_MANAGER_CLIENT "key-manager-client")
SET(TARGET_KEY_MANAGER_CONTROL_CLIENT "key-manager-control-client")
SET(TARGET_KEY_MANAGER_COMMON "key-manager-common")
-SET(TARGET_KEY_MANAGER_KEY_PROVIDER "key-manager-key-provider")
-SET(TARGET_LISTENER "key-manager-listener")
+SET(TARGET_PAM_KEY_MANAGER_PLUGIN "pam_key_manager_plugin")
-SET(TARGET_TEST_MERGED "ckm-tests-internal")
+SET(TARGET_UNIT_TESTS "ckm-unit-tests")
+PKG_CHECK_MODULES(KEY_MANAGER_DEP
+ REQUIRED
+ dlog
+ glib-2.0
+ openssl3
+ libsmack
+ libsystemd
+ capi-base-common
+ capi-system-info
+ libxml-2.0
+ security-manager
+ cynara-client-async
+ cynara-creds-socket
+ pkgmgr
+ vconf
+ sqlcipher
+ capi-system-resource
+ ${EXTRA_KM_DEPS}
+)
+
+IF (NOT DEFINED COVERAGE_ONLY)
+ADD_SUBDIRECTORY(data)
+ADD_SUBDIRECTORY(doc)
ADD_SUBDIRECTORY(src)
ADD_SUBDIRECTORY(build)
ADD_SUBDIRECTORY(systemd)
-ADD_SUBDIRECTORY(tests)
+ADD_SUBDIRECTORY(misc)
+ADD_SUBDIRECTORY(upgrade)
+ENDIF (NOT DEFINED COVERAGE_ONLY)
+
+ADD_SUBDIRECTORY(unit-tests)