7cd39ccab97636628c885c9b0a72eaa0ca37b926
[apps/agl-service-data-persistence.git] / pam_agl / CMakeLists.txt
1 ###########################################################################
2 # Copyright 2015, 2016, 2017 IoT.bzh
3 #
4 # author: Loïc Collignon <loic.collignon@iot.bzh>
5 #
6 # Licensed under the Apache License, Version 2.0 (the "License");
7 # you may not use this file except in compliance with the License.
8 # You may obtain a copy of the License at
9 #
10 #     http://www.apache.org/licenses/LICENSE-2.0
11 #
12 # Unless required by applicable law or agreed to in writing, software
13 # distributed under the License is distributed on an "AS IS" BASIS,
14 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 # See the License for the specific language governing permissions and
16 # limitations under the License.
17 ###########################################################################
18
19 cmake_minimum_required(VERSION 3.3)
20 project(pam_agl)
21
22 include(FindPkgConfig)
23
24 # Require PAM but there is no find_package
25 set(PAM_INCLUDE_DIR "/usr/include/")
26 set(PAM_LIBRARY "/lib64/libpam.so.0")
27 include_directories(${PAM_INCLUDE_DIR})
28 if (NOT DEFINED CMAKE_INSTALL_LIBDIR)
29         get_filename_component(CMAKE_INSTALL_LIBDIR ${PAM_LIBRARY} DIRECTORY)
30 endif()
31
32 # Find json-c
33 pkg_check_modules(${JSON_C} REQUIRED json-c)
34 include_directories(${${JSON_C}_INCLUDE_DIRS})
35 add_compile_options(${${JSON_C}_CFLAGS})
36
37 # Add the pam_agl_usb target
38 add_library(pam_agl_usb SHARED pam_agl_usb.c)
39 target_link_libraries(pam_agl_usb ${PAM_LIBRARY} ${${JSON_C}_LIBRARIES})
40 set_property(TARGET pam_agl_usb PROPERTY POSITION_INDEPENDENT_CODE ON)
41 set_property(TARGET pam_agl_usb PROPERTY PREFIX "")
42
43 install(TARGETS pam_agl_usb
44         LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}/security/")
45         
46 # Add the pam_agl_nfc target
47 add_library(pam_agl_nfc SHARED pam_agl_nfc.c)
48 target_link_libraries(pam_agl_nfc ${PAM_LIBRARY} ${${JSON_C}_LIBRARIES})
49 set_property(TARGET pam_agl_nfc PROPERTY POSITION_INDEPENDENT_CODE ON)
50 set_property(TARGET pam_agl_nfc PROPERTY PREFIX "")
51
52 install(TARGETS pam_agl_nfc
53         LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}/security/")