xref: /aosp_15_r20/external/libconfig/lib/CMakeLists.txt (revision 2e9d491483b805f09ea864149eadd5680efcc72a)
1*2e9d4914SAndroid Build Coastguard Workerset(libinc
2*2e9d4914SAndroid Build Coastguard Worker    libconfig.h)
3*2e9d4914SAndroid Build Coastguard Worker
4*2e9d4914SAndroid Build Coastguard Workerset(libsrc
5*2e9d4914SAndroid Build Coastguard Worker    grammar.h
6*2e9d4914SAndroid Build Coastguard Worker    parsectx.h
7*2e9d4914SAndroid Build Coastguard Worker    scanctx.h
8*2e9d4914SAndroid Build Coastguard Worker    scanner.h
9*2e9d4914SAndroid Build Coastguard Worker    win32/stdint.h
10*2e9d4914SAndroid Build Coastguard Worker    strbuf.h
11*2e9d4914SAndroid Build Coastguard Worker    strvec.h
12*2e9d4914SAndroid Build Coastguard Worker    util.h
13*2e9d4914SAndroid Build Coastguard Worker    wincompat.h
14*2e9d4914SAndroid Build Coastguard Worker    grammar.c
15*2e9d4914SAndroid Build Coastguard Worker    libconfig.c
16*2e9d4914SAndroid Build Coastguard Worker    scanctx.c
17*2e9d4914SAndroid Build Coastguard Worker    scanner.c
18*2e9d4914SAndroid Build Coastguard Worker    strbuf.c
19*2e9d4914SAndroid Build Coastguard Worker    strvec.c
20*2e9d4914SAndroid Build Coastguard Worker    util.c
21*2e9d4914SAndroid Build Coastguard Worker    wincompat.c)
22*2e9d4914SAndroid Build Coastguard Worker
23*2e9d4914SAndroid Build Coastguard Workerset(libinc_cpp
24*2e9d4914SAndroid Build Coastguard Worker    libconfig.h++
25*2e9d4914SAndroid Build Coastguard Worker    libconfig.hh)
26*2e9d4914SAndroid Build Coastguard Worker
27*2e9d4914SAndroid Build Coastguard Workerset(libsrc_cpp
28*2e9d4914SAndroid Build Coastguard Worker    ${libsrc}
29*2e9d4914SAndroid Build Coastguard Worker    libconfigcpp.cc)
30*2e9d4914SAndroid Build Coastguard Worker
31*2e9d4914SAndroid Build Coastguard Workerif(MSVC)
32*2e9d4914SAndroid Build Coastguard Worker    set(libname "libconfig")
33*2e9d4914SAndroid Build Coastguard Workerelse()
34*2e9d4914SAndroid Build Coastguard Worker    set(libname "config")
35*2e9d4914SAndroid Build Coastguard Workerendif()
36*2e9d4914SAndroid Build Coastguard Worker
37*2e9d4914SAndroid Build Coastguard Workeradd_library(${libname} ${libsrc} ${libinc})
38*2e9d4914SAndroid Build Coastguard Workeradd_library(${libname}++ ${libsrc_cpp} ${libinc_cpp})
39*2e9d4914SAndroid Build Coastguard Worker
40*2e9d4914SAndroid Build Coastguard Workerset_target_properties(${libname}
41*2e9d4914SAndroid Build Coastguard Worker    PROPERTIES LINKER_LANGUAGE C
42*2e9d4914SAndroid Build Coastguard Worker        SOVERSION "${libconfig_VERSION_MAJOR}"
43*2e9d4914SAndroid Build Coastguard Worker        VERSION "${libconfig_VERSION}"
44*2e9d4914SAndroid Build Coastguard Worker        DEFINE_SYMBOL LIBCONFIG_EXPORTS
45*2e9d4914SAndroid Build Coastguard Worker        PUBLIC_HEADER "${libinc}")
46*2e9d4914SAndroid Build Coastguard Workerset_target_properties(${libname}++
47*2e9d4914SAndroid Build Coastguard Worker    PROPERTIES LINKER_LANGUAGE CXX
48*2e9d4914SAndroid Build Coastguard Worker        SOVERSION "${libconfig_VERSION_MAJOR}"
49*2e9d4914SAndroid Build Coastguard Worker        DEFINE_SYMBOL LIBCONFIGXX_EXPORTS
50*2e9d4914SAndroid Build Coastguard Worker        VERSION "${libconfig_VERSION}"
51*2e9d4914SAndroid Build Coastguard Worker        PUBLIC_HEADER "${libinc_cpp}")
52*2e9d4914SAndroid Build Coastguard Worker
53*2e9d4914SAndroid Build Coastguard Worker#check_symbol_exists(uselocale "locale.h" HAVE_USELOCALE)
54*2e9d4914SAndroid Build Coastguard Worker#check_symbol_exists(newlocale "locale.h" HAVE_NEWLOCALE)
55*2e9d4914SAndroid Build Coastguard Worker#check_symbol_exists(freelocale "locale.h" HAVE_FREELOCALE)
56*2e9d4914SAndroid Build Coastguard Worker
57*2e9d4914SAndroid Build Coastguard Workerif(BUILD_SHARED_LIBS)
58*2e9d4914SAndroid Build Coastguard Worker    target_compile_definitions(${libname}++ PRIVATE LIBCONFIG_STATIC)
59*2e9d4914SAndroid Build Coastguard Workerelse()
60*2e9d4914SAndroid Build Coastguard Worker    target_compile_definitions(${libname} PUBLIC LIBCONFIG_STATIC)
61*2e9d4914SAndroid Build Coastguard Worker    target_compile_definitions(${libname}++ PUBLIC LIBCONFIGXX_STATIC)
62*2e9d4914SAndroid Build Coastguard Workerendif()
63*2e9d4914SAndroid Build Coastguard Worker
64*2e9d4914SAndroid Build Coastguard Workerif(HAVE_USELOCALE)
65*2e9d4914SAndroid Build Coastguard Workertarget_compile_definitions(${libname}
66*2e9d4914SAndroid Build Coastguard Worker    PRIVATE "HAVE_USELOCALE")
67*2e9d4914SAndroid Build Coastguard Workerendif()
68*2e9d4914SAndroid Build Coastguard Worker
69*2e9d4914SAndroid Build Coastguard Workerif(HAVE_NEWLOCALE)
70*2e9d4914SAndroid Build Coastguard Workertarget_compile_definitions(${libname}
71*2e9d4914SAndroid Build Coastguard Worker    PRIVATE "HAVE_NEWLOCALE")
72*2e9d4914SAndroid Build Coastguard Workerendif()
73*2e9d4914SAndroid Build Coastguard Worker
74*2e9d4914SAndroid Build Coastguard Workerif(HAVE_FREELOCALE)
75*2e9d4914SAndroid Build Coastguard Workertarget_compile_definitions(${libname}
76*2e9d4914SAndroid Build Coastguard Worker    PRIVATE "HAVE_FREELOCALE")
77*2e9d4914SAndroid Build Coastguard Workerendif()
78*2e9d4914SAndroid Build Coastguard Worker
79*2e9d4914SAndroid Build Coastguard Workerif(MSVC)
80*2e9d4914SAndroid Build Coastguard Worker    target_compile_definitions(${libname}
81*2e9d4914SAndroid Build Coastguard Worker        PRIVATE
82*2e9d4914SAndroid Build Coastguard Worker            _CRT_SECURE_NO_DEPRECATE
83*2e9d4914SAndroid Build Coastguard Worker            YY_NO_UNISTD_H
84*2e9d4914SAndroid Build Coastguard Worker            YY_USE_CONST )
85*2e9d4914SAndroid Build Coastguard Worker
86*2e9d4914SAndroid Build Coastguard Worker    target_compile_definitions(${libname}++
87*2e9d4914SAndroid Build Coastguard Worker        PRIVATE
88*2e9d4914SAndroid Build Coastguard Worker            _CRT_SECURE_NO_DEPRECATE
89*2e9d4914SAndroid Build Coastguard Worker            YY_NO_UNISTD_H
90*2e9d4914SAndroid Build Coastguard Worker            YY_USE_CONST )
91*2e9d4914SAndroid Build Coastguard Workerendif()
92*2e9d4914SAndroid Build Coastguard Worker
93*2e9d4914SAndroid Build Coastguard Workerif(WIN32)
94*2e9d4914SAndroid Build Coastguard Worker    target_link_libraries(${libname} shlwapi)
95*2e9d4914SAndroid Build Coastguard Worker    target_link_libraries(${libname}++ shlwapi)
96*2e9d4914SAndroid Build Coastguard Workerendif()
97*2e9d4914SAndroid Build Coastguard Worker
98*2e9d4914SAndroid Build Coastguard Workertarget_include_directories(${libname}
99*2e9d4914SAndroid Build Coastguard Worker  PUBLIC "$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>"
100*2e9d4914SAndroid Build Coastguard Worker  )
101*2e9d4914SAndroid Build Coastguard Worker
102*2e9d4914SAndroid Build Coastguard Workertarget_include_directories(${libname}++
103*2e9d4914SAndroid Build Coastguard Worker  PUBLIC "$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>"
104*2e9d4914SAndroid Build Coastguard Worker  )
105*2e9d4914SAndroid Build Coastguard Worker
106*2e9d4914SAndroid Build Coastguard Workerinstall(TARGETS ${libname}
107*2e9d4914SAndroid Build Coastguard Worker    EXPORT libconfigTargets
108*2e9d4914SAndroid Build Coastguard Worker    ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
109*2e9d4914SAndroid Build Coastguard Worker    LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
110*2e9d4914SAndroid Build Coastguard Worker    RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
111*2e9d4914SAndroid Build Coastguard Worker    PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
112*2e9d4914SAndroid Build Coastguard Worker)
113*2e9d4914SAndroid Build Coastguard Worker
114*2e9d4914SAndroid Build Coastguard Workerinstall(TARGETS ${libname}++
115*2e9d4914SAndroid Build Coastguard Worker    EXPORT libconfig++Targets
116*2e9d4914SAndroid Build Coastguard Worker    ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
117*2e9d4914SAndroid Build Coastguard Worker    LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
118*2e9d4914SAndroid Build Coastguard Worker    RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
119*2e9d4914SAndroid Build Coastguard Worker    PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
120*2e9d4914SAndroid Build Coastguard Worker)
121*2e9d4914SAndroid Build Coastguard Worker
122*2e9d4914SAndroid Build Coastguard Worker
123*2e9d4914SAndroid Build Coastguard Workerinclude(CMakePackageConfigHelpers)
124*2e9d4914SAndroid Build Coastguard Workerforeach(target_name libconfig libconfig++)
125*2e9d4914SAndroid Build Coastguard Worker  write_basic_package_version_file("${target_name}ConfigVersion.cmake"
126*2e9d4914SAndroid Build Coastguard Worker    VERSION ${PACKAGE_VERSION}
127*2e9d4914SAndroid Build Coastguard Worker    COMPATIBILITY SameMajorVersion
128*2e9d4914SAndroid Build Coastguard Worker    )
129*2e9d4914SAndroid Build Coastguard Worker
130*2e9d4914SAndroid Build Coastguard Worker  install(EXPORT ${target_name}Targets
131*2e9d4914SAndroid Build Coastguard Worker    FILE "${target_name}Config.cmake"
132*2e9d4914SAndroid Build Coastguard Worker    NAMESPACE libconfig::
133*2e9d4914SAndroid Build Coastguard Worker    DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/libconfig
134*2e9d4914SAndroid Build Coastguard Worker    )
135*2e9d4914SAndroid Build Coastguard Worker
136*2e9d4914SAndroid Build Coastguard Worker  install(FILES
137*2e9d4914SAndroid Build Coastguard Worker    "${CMAKE_CURRENT_BINARY_DIR}/${target_name}ConfigVersion.cmake"
138*2e9d4914SAndroid Build Coastguard Worker    DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/libconfig"
139*2e9d4914SAndroid Build Coastguard Worker    )
140*2e9d4914SAndroid Build Coastguard Workerendforeach()
141