Fix:graphics_win32:Transform non-opaque, grayscale etc png files to RGBA format properly.
[profile/ivi/navit.git] / navit / cmake / navit_macros.cmake
1 macro(internal_set VARIABLE REASON)
2    if (NOT DEFINED ${VARIABLE})
3       set(${VARIABLE} ${ARGN})
4       set(${VARIABLE}_REASON ${REASON} CACHE STRING "reason")
5    else()
6       set(${VARIABLE}_REASON "User defined" CACHE STRING "reason")
7    endif()
8 endmacro()
9
10 macro(set_with_reason VARIABLE REASON ENABLE)
11    if (DEFINED ${VARIABLE}_REASON AND NOT ${VARIABLE}_REASON STREQUAL "User defined")
12       set(${VARIABLE} ${ENABLE})
13       set(${VARIABLE}_REASON ${REASON})
14       string(REPLACE "/" "_" VARIABLE_NAMES ${VARIABLE})
15       set(${VARIABLE_NAMES}_LIBS ${ARGN})
16    else()
17       message("Do not change user defined settings for ${VARIABLE}")
18    endif()
19 endmacro()
20
21 macro(add_feature FEATURE REASON ENABLE)
22    list(APPEND ALL_FEATURES ${FEATURE})
23    internal_set(${FEATURE} ${REASON} ${ENABLE})
24 endmacro()
25
26 macro(cfg_feature FEATURE REASON ENABLE)
27    set(${FEATURE} ${ENABLE})
28    set(${FEATURE}_REASON ${REASON})
29 endmacro()
30
31 macro(add_module MODULE_PATH REASON ENABLE)
32    list(APPEND ALL_MODULES ${MODULE_PATH})
33    internal_set(${MODULE_PATH} ${REASON} ${ENABLE})
34 endmacro()
35
36 # plugins are always linked static
37 macro(add_plugin PLUGIN_PATH REASON ENABLE)
38    list(APPEND ALL_PLUGINS ${PLUGIN_PATH})
39    internal_set(${PLUGIN_PATH} ${REASON} ${ENABLE})
40 endmacro()
41
42 # module plugins are always linked static
43 macro(add_module_plugin PLUGIN_PATH REASON ENABLE)
44    list(APPEND ALL_MODULE_PLUGINS ${PLUGIN_PATH})
45    internal_set(${PLUGIN_PATH} ${REASON} ${ENABLE})
46 endmacro()
47
48 macro(module_add_library MODULE_NAME )
49    LINK_DIRECTORIES(${${MODULE_NAME}_LIBRARY_DIRS}) 
50    add_library(${MODULE_NAME} ${MODULE_BUILD_TYPE} ${ARGN})
51    SET_TARGET_PROPERTIES(${MODULE_NAME} PROPERTIES COMPILE_DEFINITIONS "MODULE=${MODULE_NAME}")
52    TARGET_LINK_LIBRARIES(${MODULE_NAME} ${${MODULE_NAME}_LIBS})
53    SET_TARGET_PROPERTIES( ${MODULE_NAME} PROPERTIES COMPILE_FLAGS "${NAVIT_COMPILE_FLAGS} ${${MODULE_NAME}_FLAGS}")
54    INCLUDE_DIRECTORIES(${${MODULE_NAME}_INCLUDES}) 
55    if (USE_PLUGINS)
56        if (ANDROID)
57            TARGET_LINK_LIBRARIES(${MODULE_NAME} ${NAVIT_LIBNAME})
58        endif()
59        if (APPLE)
60            set_target_properties( ${MODULE_NAME} PROPERTIES LINK_FLAGS "-Wl,-undefined -Wl,dynamic_lookup") 
61        endif()
62       # workaround to be compatible with old paths
63       set_target_properties( ${MODULE_NAME} PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/.libs")
64
65       install(TARGETS ${MODULE_NAME}
66               DESTINATION ${LIB_DIR}/navit/${${MODULE_NAME}_TYPE}
67               PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
68    endif()
69 endmacro(module_add_library)
70
71 macro(supportlib_add_library LIB_NAME )
72    add_library(${LIB_NAME} ${ARGN})
73    TARGET_LINK_LIBRARIES(${LIB_NAME} ${${LIB_NAME}_LIBS})
74    SET_TARGET_PROPERTIES( ${LIB_NAME} PROPERTIES COMPILE_FLAGS "${NAVIT_COMPILE_FLAGS}")
75    SET_TARGET_PROPERTIES(${LIB_NAME} PROPERTIES COMPILE_DEFINITIONS "MODULE=${LIB_NAME}")
76 endmacro(supportlib_add_library)
77
78 macro(message_error)
79    set(NAVIT_DEPENDENCY_ERROR 1)
80    message( SEND_ERROR ${ARGN})
81 endmacro(message_error)