66 lines
1.6 KiB
CMake
66 lines
1.6 KiB
CMake
cmake_minimum_required(VERSION 3.7)
|
|
set(NAME asn1)
|
|
set(TARGET lib${NAME})
|
|
project(Cnomicon-${TARGET})
|
|
set(CMAKE_INSTALL_PREFIX ..)
|
|
set(LIBRARY ${TARGET})
|
|
|
|
# list of header files
|
|
set(LIBH
|
|
asn1common.h
|
|
asn1oer.h
|
|
asn1uper.h
|
|
)
|
|
|
|
# list of source files
|
|
set(LIBSRC
|
|
asn1_debug.c
|
|
oer_stream.c oer_decode.c oer_encode.c
|
|
oer_get_bits.c oer_put_bits.c
|
|
oer_get_ext.c oer_put_ext.c
|
|
oer_get_octet.c oer_put_octet.c
|
|
uper_stream.c uper_decode.c uper_encode.c
|
|
uper_get_bits.c uper_put_bits.c
|
|
uper_get_ext.c uper_put_ext.c
|
|
uper_get_octet.c uper_put_octet.c
|
|
)
|
|
|
|
# includes
|
|
include_directories(
|
|
../include
|
|
)
|
|
link_directories(../lib)
|
|
|
|
link_libraries(
|
|
json-c.a
|
|
pcap.a
|
|
m
|
|
)
|
|
|
|
# executables
|
|
#add_executable(test_${NAME}_uper test_${NAME}_uper.c)
|
|
|
|
# includes
|
|
include_directories(../include)
|
|
|
|
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../lib)
|
|
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../lib)
|
|
|
|
# this is the "object library" target: compiles the sources only once
|
|
add_library(${LIBRARY} OBJECT ${LIBSRC})
|
|
|
|
# shared libraries need PIC
|
|
set_property(TARGET ${LIBRARY} PROPERTY POSITION_INDEPENDENT_CODE 1)
|
|
|
|
# shared and static libraries built from the same object files
|
|
add_library(${LIBRARY}-shared SHARED $<TARGET_OBJECTS:${LIBRARY}>)
|
|
add_library(${LIBRARY}-static STATIC $<TARGET_OBJECTS:${LIBRARY}>)
|
|
|
|
# output file names
|
|
set_target_properties(${LIBRARY}-shared PROPERTIES OUTPUT_NAME ${NAME})
|
|
set_target_properties(${LIBRARY}-static PROPERTIES OUTPUT_NAME ${NAME})
|
|
|
|
# installations
|
|
install (FILES ${LIBH} DESTINATION include)
|
|
#install (FILES lib${NAME}.a lib${NAME}.so DESTINATION lib)
|