-# Copyright (c) 2017 - 2019 Samsung Electronics Co., Ltd All Rights Reserved
+# Copyright (c) 2017 - 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.
# @author Jaroslaw Pelczar <j.pelczar@samsung.com>
#
-CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
-
-IF(POLICY CMP0048)
- CMAKE_POLICY(SET CMP0048 NEW)
-ENDIF()
+CMAKE_MINIMUM_REQUIRED(VERSION 3.0)
INCLUDE(GNUInstallDirs)
-INCLUDE(cmake/CheckFrameworks.cmake)
+INCLUDE(CheckLibraryExists)
IF(NOT CMAKE_BUILD_TYPE)
SET(CMAKE_BUILD_TYPE "RELEASE")
SET(CMAKE_POSITION_INDEPENDENT_CODE "True")
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pie")
-INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR})
-
-ADD_SUBDIRECTORY(src)
+IF(DCM_BACKEND_TYPE STREQUAL "dummy")
+ ADD_SUBDIRECTORY(src/dummy-backend)
+ELSEIF(DCM_BACKEND_TYPE STREQUAL "kse")
+ ADD_SUBDIRECTORY(src/kse-backend)
+ELSE()
+ ADD_SUBDIRECTORY(src/dummy-backend)
+ENDIF()
+++ /dev/null
-INCLUDE(CheckIncludeFile)
-INCLUDE(CheckIncludeFileCXX)
-INCLUDE(CheckLibraryExists)
-INCLUDE(CheckFunctionExists)
-INCLUDE(CheckIncludeFiles)
-
-FIND_PACKAGE(PkgConfig REQUIRED)
-
-PKG_CHECK_MODULES(DLOG REQUIRED dlog)
-
-#### Find mbedtls ####
-
-find_library(MBEDTLS_LIB
- mbedtls)
-
-find_library(MBEDCRYPTO_LIB
- mbedcrypto)
-
-find_library(MBEDX509_LIB
- mbedx509)
-
-IF(MBEDTLS_LIB-NOTFOUND)
- message(FATAL_ERROR "mbedtls not found ...")
-ENDIF()
-
-IF(MBEDCRYPTO_LIB-NOTFOUND)
- message(FATAL_ERROR "mbedcrypto not found ...")
-ENDIF()
-
-IF(MBEDX509_LIB-NOTFOUND)
- message(FATAL_ERROR "mbedx509 not found ...")
-ENDIF()
-
-CHECK_INCLUDE_FILES("mbedtls/rsa.h;mbedtls/ecdsa.h" MBEDTLS_HEADERS_OK)
-
-IF(NOT MBEDTLS_HEADERS_OK)
- message(FATAL_ERROR "No mbedtls headers")
-ENDIF()
-
-#### Find dcm-backend-api.h header ####
-
-FIND_FILE(DCM_BACKEND_API_H device-certificate-manager-backend/dcm-backend-api.h)
-IF(NOT DCM_BACKEND_API_H)
- message(FATAL_ERROR "No dcm-backend-api.h")
-ENDIF()
+++ /dev/null
-#
-# DCM backends build script
-# Jaroslaw Pelczar <j.pelczar@samsung.com>
-#
-
-###### Setup include paths and library directories #######
-
-include_directories(${DLOG_INCLUDE_DIRS})
-link_directories(${DLOG_LIBRARY_DIRS})
-
-include_directories(${Boost_INCLUDE_DIRS})
-include_directories(device-certificate-manager)
-link_directories(${Boost_LIBRARY_DIRS})
-
-include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
-
-###### Crypto Backends #######
-
-ADD_DEFINITIONS(-DDCM_BACKEND)
-
-IF(DCM_BACKEND_TYPE STREQUAL "dummy")
- add_subdirectory(dummy-backend)
-ELSEIF(DCM_BACKEND_TYPE STREQUAL "kse")
- add_subdirectory(kse-backend)
-ELSE()
- add_subdirectory(dummy-backend)
-ENDIF()
-# Copyright (c) 2017 - 2019 Samsung Electronics Co., Ltd All Rights Reserved
+# Copyright (c) 2017 - 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.
# @author Jaroslaw Pelczar <j.pelczar@samsung.com>
#
-find_program(OPENSSL_TOOL openssl)
+FIND_PROGRAM(OPENSSL_TOOL openssl REQUIRED)
+FIND_PACKAGE(PkgConfig REQUIRED)
+FIND_LIBRARY(MBEDTLS_LIB mbedtls)
+FIND_LIBRARY(MBEDCRYPTO_LIB mbedcrypto)
-IF(NOT OPENSSL_TOOL)
- MESSAGE(FATAL_ERROR "openssl required to build dummy CA")
-ENDIF()
+ADD_EXECUTABLE(bin2c bin2c.c)
-add_executable(helper_bin2c bin2c.c)
-
-add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/rootCA.key
+ADD_CUSTOM_COMMAND(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/rootCA.key
COMMAND ${OPENSSL_TOOL} genrsa -out ${CMAKE_CURRENT_BINARY_DIR}/rootCA.key 1024)
-add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/rootCA.pem
+ADD_CUSTOM_COMMAND(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/rootCA.pem
COMMAND ${OPENSSL_TOOL} req -x509 -new -nodes -key ${CMAKE_CURRENT_BINARY_DIR}/rootCA.key
-sha256 -days 1024 -out ${CMAKE_CURRENT_BINARY_DIR}/rootCA.pem
-subj "/C=PL/ST=Test1/L=Test2/O=Dis/CN=www.example.com"
- DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/rootCA.key)
+ DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/rootCA.key)
-add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/rootECDSA.key
+ADD_CUSTOM_COMMAND(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/rootECDSA.key
COMMAND ${OPENSSL_TOOL} ecparam -name secp521r1 -genkey -noout -out ${CMAKE_CURRENT_BINARY_DIR}/rootECDSA.key)
-add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/rootECDSA.pem
+ADD_CUSTOM_COMMAND(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/rootECDSA.pem
COMMAND ${OPENSSL_TOOL} req -x509 -new -nodes -key ${CMAKE_CURRENT_BINARY_DIR}/rootECDSA.key
-sha256 -days 1024 -out ${CMAKE_CURRENT_BINARY_DIR}/rootECDSA.pem
-subj "/C=PL/ST=Test1/L=Test2/O=Dis/CN=www.example.com"
- DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/rootECDSA.key)
-
-add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/rootCA_rsa_key.c
- COMMAND $<TARGET_FILE:helper_bin2c> ${CMAKE_CURRENT_BINARY_DIR}/rootCA.key ${CMAKE_CURRENT_BINARY_DIR}/rootCA_rsa_key.c dummy_rootca_rsa_key
- DEPENDS helper_bin2c ${CMAKE_CURRENT_BINARY_DIR}/rootCA.key)
-
-add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/rootCA_rsa_cert.c
- COMMAND $<TARGET_FILE:helper_bin2c> ${CMAKE_CURRENT_BINARY_DIR}/rootCA.pem ${CMAKE_CURRENT_BINARY_DIR}/rootCA_rsa_cert.c dummy_rootca_rsa_cert
- DEPENDS helper_bin2c ${CMAKE_CURRENT_BINARY_DIR}/rootCA.pem)
+ DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/rootECDSA.key)
-add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/rootCA_ecdsa_key.c
- COMMAND $<TARGET_FILE:helper_bin2c> ${CMAKE_CURRENT_BINARY_DIR}/rootECDSA.key ${CMAKE_CURRENT_BINARY_DIR}/rootCA_ecdsa_key.c dummy_rootca_ecdsa_key
- DEPENDS helper_bin2c ${CMAKE_CURRENT_BINARY_DIR}/rootECDSA.key)
+ADD_CUSTOM_COMMAND(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/rootCA_rsa_key.c
+ COMMAND $<TARGET_FILE:bin2c> ${CMAKE_CURRENT_BINARY_DIR}/rootCA.key ${CMAKE_CURRENT_BINARY_DIR}/rootCA_rsa_key.c dummy_rootca_rsa_key
+ DEPENDS bin2c ${CMAKE_CURRENT_BINARY_DIR}/rootCA.key)
-add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/rootCA_ecdsa_cert.c
- COMMAND $<TARGET_FILE:helper_bin2c> ${CMAKE_CURRENT_BINARY_DIR}/rootECDSA.pem ${CMAKE_CURRENT_BINARY_DIR}/rootCA_ecdsa_cert.c dummy_rootca_ecdsa_cert
- DEPENDS helper_bin2c ${CMAKE_CURRENT_BINARY_DIR}/rootECDSA.pem)
+ADD_CUSTOM_COMMAND(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/rootCA_rsa_cert.c
+ COMMAND $<TARGET_FILE:bin2c> ${CMAKE_CURRENT_BINARY_DIR}/rootCA.pem ${CMAKE_CURRENT_BINARY_DIR}/rootCA_rsa_cert.c dummy_rootca_rsa_cert
+ DEPENDS bin2c ${CMAKE_CURRENT_BINARY_DIR}/rootCA.pem)
-###### Include and library directories ######
+ADD_CUSTOM_COMMAND(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/rootCA_ecdsa_key.c
+ COMMAND $<TARGET_FILE:bin2c> ${CMAKE_CURRENT_BINARY_DIR}/rootECDSA.key ${CMAKE_CURRENT_BINARY_DIR}/rootCA_ecdsa_key.c dummy_rootca_ecdsa_key
+ DEPENDS bin2c ${CMAKE_CURRENT_BINARY_DIR}/rootECDSA.key)
-include_directories(${DLOG_INCLUDE_DIRS})
-link_directories(${DLOG_LIBRARY_DIRS})
+ADD_CUSTOM_COMMAND(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/rootCA_ecdsa_cert.c
+ COMMAND $<TARGET_FILE:bin2c> ${CMAKE_CURRENT_BINARY_DIR}/rootECDSA.pem ${CMAKE_CURRENT_BINARY_DIR}/rootCA_ecdsa_cert.c dummy_rootca_ecdsa_cert
+ DEPENDS bin2c ${CMAKE_CURRENT_BINARY_DIR}/rootECDSA.pem)
-include_directories(${Boost_INCLUDE_DIRS})
-link_directories(${Boost_LIBRARY_DIRS})
+PKG_CHECK_MODULES(DUMMY_DEPS REQUIRED dlog device-certificate-manager-backend)
+INCLUDE_DIRECTORIES(SYSTEM ${DUMMY_DEPS_INCLUDE_DIRS})
+LINK_DIRECTORIES(${DUMMY_DEPS_LIBRARY_DIRS})
-include_directories(${CMAKE_CURRENT_BINARY_DIR})
+INCLUDE_DIRECTORIES(../shared)
-###### Library sources ######
-
-add_library(${DCM_BACKEND_API}
+ADD_LIBRARY(${DCM_BACKEND_API}
SHARED
dcm-backend-api-dummy.cpp
dummycryptobackendcontext.cpp
- ../log.cpp
+ ../shared/log.cpp
${CMAKE_CURRENT_BINARY_DIR}/rootCA_ecdsa_key.c
${CMAKE_CURRENT_BINARY_DIR}/rootCA_ecdsa_cert.c
${CMAKE_CURRENT_BINARY_DIR}/rootCA_rsa_key.c
- ${CMAKE_CURRENT_BINARY_DIR}/rootCA_rsa_cert.c
-)
+ ${CMAKE_CURRENT_BINARY_DIR}/rootCA_rsa_cert.c)
-###### Linking ######
-target_link_libraries(${DCM_BACKEND_API}
- ${Boost_SYSTEM_LIBRARY}
- ${CMAKE_THREAD_LIBS_INIT}
+TARGET_LINK_LIBRARIES(${DCM_BACKEND_API}
${MBEDTLS_LIB}
${MBEDCRYPTO_LIB}
- ${DLOG_LIBRARIES}
-)
-
-###### Properties of library ######
-
-set_property(TARGET ${DCM_BACKEND_API} PROPERTY DEFINE_SYMBOL DCM_BACKEND_API_DUMMY_EXPORT)
-set_property(TARGET ${DCM_BACKEND_API} PROPERTY VISIBILITY_INLINES_HIDDEN TRUE)
-set_property(TARGET ${DCM_BACKEND_API} PROPERTY VERSION 1.0)
-set_property(TARGET ${DCM_BACKEND_API} PROPERTY C_VISIBILITY_PRESET hidden)
-set_property(TARGET ${DCM_BACKEND_API} PROPERTY CXX_VISIBILITY_PRESET hidden)
+ ${DUMMY_DEPS_LIBRARIES})
-###### Installation ######
+SET_TARGET_PROPERTIES(${DCM_BACKEND_API}
+ PROPERTIES
+ VERSION 1.0
+ DEFINE_SYMBOL DCM_BACKEND_API_DUMMY_EXPORT
+ VISIBILITY_INLINES_HIDDEN TRUE
+ C_VISIBILITY_PRESET hidden
+ CXX_VISIBILITY_PRESET hidden)
-install(TARGETS
- ${DCM_BACKEND_API}
+INSTALL(TARGETS ${DCM_BACKEND_API}
LIBRARY DESTINATION
- ${CMAKE_INSTALL_LIBDIR}
-)
+ ${CMAKE_INSTALL_LIBDIR})
-# Copyright (c) 2019 Samsung Electronics Co., Ltd All Rights Reserved
+# Copyright (c) 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.
# @author Pawel Kowalski <p.kowalski2@partner.samsung.com>
#
-###### Include and library directories ######
+FIND_PACKAGE(PkgConfig REQUIRED)
+FIND_LIBRARY(MBEDTLS_LIB mbedtls)
-include_directories(${DLOG_INCLUDE_DIRS})
-link_directories(${DLOG_LIBRARY_DIRS})
+PKG_CHECK_MODULES(KSE_DEPS REQUIRED dlog device-certificate-manager-backend)
+INCLUDE_DIRECTORIES(SYSTEM ${KSE_DEPS_INCLUDE_DIRS})
+LINK_DIRECTORIES(${KSE_DEPS_LIBRARY_DIRS})
-include_directories(${Boost_INCLUDE_DIRS})
-link_directories(${Boost_LIBRARY_DIRS})
+INCLUDE_DIRECTORIES(../shared)
-include_directories(${CMAKE_CURRENT_BINARY_DIR})
-
-###### Library sources ######
-
-add_library(${DCM_BACKEND_API}
+ADD_LIBRARY(${DCM_BACKEND_API}
SHARED
dcm-backend-api-kse.cpp
soresolver.cpp
ksebackend.cpp
ksebackendcontext.cpp
- ../log.cpp
-)
+ ../shared/log.cpp)
-###### Linking ######
-target_link_libraries(${DCM_BACKEND_API}
- ${Boost_SYSTEM_LIBRARY}
- ${CMAKE_THREAD_LIBS_INIT}
+TARGET_LINK_LIBRARIES(${DCM_BACKEND_API}
${MBEDTLS_LIB}
- ${MBEDCRYPTO_LIB}
- ${DLOG_LIBRARIES}
-)
-
-###### Properties of library ######
-
-set_property(TARGET ${DCM_BACKEND_API} PROPERTY DEFINE_SYMBOL DCM_BACKEND_API_SEE_EXPORT)
-set_property(TARGET ${DCM_BACKEND_API} PROPERTY VISIBILITY_INLINES_HIDDEN TRUE)
-set_property(TARGET ${DCM_BACKEND_API} PROPERTY VERSION 1.0)
-set_property(TARGET ${DCM_BACKEND_API} PROPERTY C_VISIBILITY_PRESET hidden)
-set_property(TARGET ${DCM_BACKEND_API} PROPERTY CXX_VISIBILITY_PRESET hidden)
+ ${KSE_DEPS_LIBRARIES})
-###### Installation ######
+SET_TARGET_PROPERTIES(${DCM_BACKEND_API}
+ PROPERTIES
+ VERSION 1.0
+ DEFINE_SYMBOL DCM_BACKEND_API_SEE_EXPORT
+ VISIBILITY_INLINES_HIDDEN TRUE
+ C_VISIBILITY_PRESET hidden
+ CXX_VISIBILITY_PRESET hidden)
-install(TARGETS
- ${DCM_BACKEND_API}
+INSTALL(TARGETS ${DCM_BACKEND_API}
LIBRARY DESTINATION
- ${CMAKE_INSTALL_LIBDIR}
-)
+ ${CMAKE_INSTALL_LIBDIR})
ADD_SUBDIRECTORY(tools)
-#######################################################################################
-# For SE_KONAI
+# Copyright (c) 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.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# @file src/kse-backend/CMakeLists.txt
+# @author Pawel Kowalski <p.kowalski2@partner.samsung.com>
+#
-include_directories(${Boost_INCLUDE_DIRS})
-link_directories(${Boost_LIBRARY_DIRS})
+FIND_PACKAGE(PkgConfig REQUIRED)
-include_directories(../src ../src/kse-backend)
+PKG_CHECK_MODULES(TOOL_DEPS REQUIRED dlog)
+INCLUDE_DIRECTORIES(SYSTEM ${TOOL_DEPS_INCLUDE_DIRS})
+LINK_DIRECTORIES(${TOOL_DEPS_LIBRARY_DIRS})
-add_executable(dcm_konaise_tool
+INCLUDE_DIRECTORIES(../ ../../shared)
+
+SET(TARGET_TOOL "dcm_konaise_tool")
+ADD_EXECUTABLE(${TARGET_TOOL}
+ konaise_tool.cpp
../soresolver.cpp
- ../../log.cpp
- konaise_tool.cpp)
+ ../../shared/log.cpp)
-target_link_libraries(dcm_konaise_tool
- ${Boost_SYSTEM_LIBRARY}
- dl
- ${CMAKE_THREAD_LIBS_INIT}
- ${DLOG_LIBRARIES}
-)
+TARGET_LINK_LIBRARIES(${TARGET_TOOL} ${TOOL_DEPS_LIBRARIES} dl)
-install(TARGETS dcm_konaise_tool RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
-#######################################################################################
+INSTALL(TARGETS ${TARGET_TOOL}
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})