updated CMakeLists.txt with license and fixed a wrong path
[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
29 # Find json-c
30 pkg_check_modules(${JSON_C} REQUIRED json-c)
31 include_directories(${${JSON_C}_INCLUDE_DIRS})
32 add_compile_options(${${JSON_C}_CFLAGS})
33
34 # Add the target
35 add_library(pam_agl SHARED pam_agl.c)
36 target_link_libraries(pam_agl ${PAM_LIBRARY} ${${JSON_C}_LIBRARIES})
37 #list (APPEND link_libraries ${${JSON_C}_LDFLAGS})
38 set_property(TARGET pam_agl PROPERTY POSITION_INDEPENDENT_CODE ON)
39 set_property(TARGET pam_agl PROPERTY PREFIX "")
40
41 if (NOT DEFINED CMAKE_INSTALL_LIBDIR)
42         get_filename_component(CMAKE_INSTALL_LIBDIR ${PAM_LIBRARY} DIRECTORY)
43 endif()
44
45 install(TARGETS pam_agl
46         LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}/security/")