aboutsummaryrefslogtreecommitdiff
path: root/ports/cspice/CMakeLists.txt
blob: af5c3e22b15a82be5734431601a8024294b0c54c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
cmake_minimum_required(VERSION 3.1)
project(cspice LANGUAGES C)

set(SOVERSION 66)

# Include all *.c files from the library
file(GLOB CSPICE_SOURCE ${PROJECT_SOURCE_DIR}/cspice/src/cspice/*.c)
set(INCLUDE_PATH "${PROJECT_SOURCE_DIR}/cspice/include")

if (_STATIC_BUILD)
    add_library(cspice STATIC ${CSPICE_SOURCE})
else()
    add_library(cspice SHARED ${CSPICE_SOURCE})
endif()
target_include_directories(cspice PUBLIC "${INCLUDE_PATH}")

if (WIN32)
    target_compile_definitions(cspice PUBLIC "_COMPLEX_DEFINED;MSDOS;OMIT_BLANK_CC;NON_ANSI_STDIO")
    set_target_properties(cspice PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS TRUE)
elseif (UNIX)
    target_compile_definitions(cspice PUBLIC "NON_UNIX_STDIO")
    if(CMAKE_SIZEOF_VOID_P EQUAL 8)
        target_compile_options(cspice PUBLIC -m64 -ansi -fPIC)
    elseif(CMAKE_SIZEOF_VOID_P EQUAL 4)
        target_compile_options(cspice PUBLIC -m32 -ansi -fPIC) 
    endif()
endif ()

if (NOT _SKIP_HEADERS)
    file(GLOB SPICE_HEADERS ${INCLUDE_PATH}/*.h)
    install(FILES ${SPICE_HEADERS} DESTINATION include/cspice)
endif()

set_target_properties(
    cspice
    PROPERTIES SOVERSION ${SOVERSION}
)

install(
    TARGETS cspice
    EXPORT cspice
    ARCHIVE DESTINATION lib
    LIBRARY DESTINATION lib
    RUNTIME DESTINATION bin
)