summaryrefslogtreecommitdiff
path: root/src/libcalamares/CMakeLists.txt
blob: 2173c825cbb1b9bffe5ab37697dbb20012a2996b (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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
add_definitions(
    ${QT_DEFINITIONS}
    -DQT_SHARED
    -DQT_SHAREDPOINTER_TRACK_POINTERS
    -DDLLEXPORT_PRO
)

configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/CalamaresConfig.h.in
                ${CMAKE_CURRENT_BINARY_DIR}/CalamaresConfig.h )
configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/../calamares/CalamaresVersion.h.in
                ${CMAKE_CURRENT_BINARY_DIR}/CalamaresVersion.h )

set( libSources
    CppJob.cpp
    GlobalStorage.cpp
    Job.cpp
    JobExample.cpp
    JobQueue.cpp
    ProcessJob.cpp
    Settings.cpp
)
set( utilsSources
    utils/CalamaresUtilsSystem.cpp
    utils/CommandList.cpp
    utils/Dirs.cpp
    utils/LocaleLabel.cpp
    utils/Logger.cpp
    utils/PluginFactory.cpp
    utils/Retranslator.cpp
    utils/String.cpp
    utils/Variant.cpp
    utils/Yaml.cpp
)
set( kdsagSources
    kdsingleapplicationguard/kdsingleapplicationguard.cpp
    kdsingleapplicationguard/kdsharedmemorylocker.cpp
    kdsingleapplicationguard/kdtoolsglobal.cpp
    kdsingleapplicationguard/kdlockedsharedmemorypointer.cpp
)
mark_thirdparty_code( ${kdsagSources} )

include_directories(
    ${CMAKE_CURRENT_BINARY_DIR}
    ${CMAKE_CURRENT_SOURCE_DIR}
    ${YAMLCPP_INCLUDE_DIR}
)

if( WITH_PYTHON )
    set( libSources
        ${libSources}
        PythonHelper.cpp
        PythonJob.cpp
        PythonJobApi.cpp
    )
    set_source_files_properties( PythonJob.cpp
        PROPERTIES COMPILE_FLAGS "${SUPPRESS_BOOST_WARNINGS}"
    )

    include_directories(${PYTHON_INCLUDE_DIRS})
    link_directories(${PYTHON_LIBRARIES})

    include_directories(${Boost_INCLUDE_DIRS})
    link_directories(${Boost_LIBRARY_DIRS})

    set( OPTIONAL_PRIVATE_LIBRARIES
        ${OPTIONAL_PRIVATE_LIBRARIES}
        ${PYTHON_LIBRARIES}
        ${Boost_LIBRARIES}
    )
endif()

set( geoipSources
    geoip/Interface.cpp
    geoip/Handler.cpp
)
set( geoipImplementations geoip/GeoIPJSON.cpp )
set( geoip_libs )

find_package(Qt5 COMPONENTS Xml)
if( Qt5Xml_FOUND )
    list( APPEND geoipImplementations geoip/GeoIPXML.cpp )
    list( APPEND geoip_libs Qt5::Network Qt5::Xml )
endif()

add_library( calamares SHARED ${libSources} ${kdsagSources} ${utilsSources} ${geoipSources} ${geoipImplementations} )
set_target_properties( calamares
    PROPERTIES
        VERSION ${CALAMARES_VERSION_SHORT}
        SOVERSION ${CALAMARES_VERSION_SHORT}
)
calamares_automoc( calamares )

target_link_libraries( calamares
    LINK_PRIVATE
        ${OPTIONAL_PRIVATE_LIBRARIES}
    LINK_PUBLIC
        ${YAMLCPP_LIBRARY}
        ${geoip_libs}
        Qt5::Core
)

install( TARGETS calamares
    EXPORT CalamaresLibraryDepends
    RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
    LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
    ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
)

if ( ECM_FOUND AND BUILD_TESTING )
    ecm_add_test(
            Tests.cpp
        TEST_NAME
            libcalamarestest
        LINK_LIBRARIES
            calamares
            Qt5::Core
            Qt5::Test
    )
    calamares_automoc( libcalamarestest )

    ecm_add_test(
            geoip/GeoIPTests.cpp
            ${geoip_src}
        TEST_NAME
            geoiptest
        LINK_LIBRARIES
            calamares
            Qt5::Test
            ${YAMLCPP_LIBRARY}
    )
    calamares_automoc( geoiptest )
endif()

if( BUILD_TESTING )
    add_executable( test_geoip geoip/test_geoip.cpp ${geoip_src} )
    target_link_libraries( test_geoip calamares Qt5::Network ${YAMLCPP_LIBRARY} )
    calamares_automoc( test_geoip )
endif()

# Make symlink lib/calamares/libcalamares.so to lib/libcalamares.so.VERSION so
# lib/calamares can be used as module path for the Python interpreter.
install( CODE "
    file( MAKE_DIRECTORY \"\$ENV{DESTDIR}/${CMAKE_INSTALL_FULL_LIBDIR}/calamares\" )
    execute_process( COMMAND \"${CMAKE_COMMAND}\" -E create_symlink ../libcalamares.so.${CALAMARES_VERSION_SHORT} libcalamares.so WORKING_DIRECTORY \"\$ENV{DESTDIR}/${CMAKE_INSTALL_FULL_LIBDIR}/calamares\" )
")

# Install header files
file( GLOB rootHeaders "*.h" )
file( GLOB kdsingleapplicationguardHeaders "kdsingleapplicationguard/*.h" )
file( GLOB utilsHeaders "utils/*.h" )

install( FILES ${CMAKE_CURRENT_BINARY_DIR}/CalamaresConfig.h DESTINATION include/libcalamares )
install( FILES ${rootHeaders}                       DESTINATION include/libcalamares )
install( FILES ${kdsingleapplicationguardHeaders}   DESTINATION include/libcalamares/kdsingleapplicationguard )
install( FILES ${utilsHeaders}                      DESTINATION include/libcalamares/utils )