forked from osmandapp/OsmAnd-resources
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
70 lines (61 loc) · 2.83 KB
/
CMakeLists.txt
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
project(OsmAndCore_ResourcesBundle)
set(OsmAndCore_ResourcesBundle_src "")
set(OsmAndCore_ResourcesCppIndex_src
"${CMAKE_CURRENT_LIST_DIR}/embed-resources-cpp.index")
if (EXISTS ${OsmAndCore_ResourcesCppIndex_src})
if (CMAKE_HOST_WIN32 AND NOT CYGWIN)
file(STRINGS ${OsmAndCore_ResourcesCppIndex_src} OsmAndCore_ResourcesBundle_src)
set(listVar "")
foreach(f ${OsmAndCore_ResourcesBundle_src})
set(listVar ${listVar} "${CMAKE_CURRENT_BINARY_DIR}${f}")
endforeach(f)
set(OsmAndCore_ResourcesBundle_src ${listVar})
set_source_files_properties(${OsmAndCore_ResourcesBundle_src} PROPERTIES GENERATED TRUE)
add_custom_command(OUTPUT ${OsmAndCore_ResourcesBundle_src}
PRE_BUILD
COMMAND bash ARGS --login "${CMAKE_CURRENT_LIST_DIR}/embed-resources.sh" "${CMAKE_CURRENT_BINARY_DIR}"
DEPENDS
"${CMAKE_CURRENT_LIST_DIR}/embed-resources-cpp.index"
"${CMAKE_CURRENT_LIST_DIR}/embed-resources.index"
"${CMAKE_CURRENT_LIST_DIR}/embed-resources.sh"
"${CMAKE_CURRENT_LIST_DIR}/embed-resources.py"
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
COMMENT "Embedding resources...")
else()
file(STRINGS ${OsmAndCore_ResourcesCppIndex_src} OsmAndCore_ResourcesBundle_src)
set(listVar "")
foreach(f ${OsmAndCore_ResourcesBundle_src})
set(listVar ${listVar} "${CMAKE_CURRENT_BINARY_DIR}${f}")
endforeach(f)
set(OsmAndCore_ResourcesBundle_src ${listVar})
set_source_files_properties(${OsmAndCore_ResourcesBundle_src} PROPERTIES GENERATED TRUE)
add_custom_command(OUTPUT ${OsmAndCore_ResourcesBundle_src}
PRE_BUILD
COMMAND "${CMAKE_CURRENT_LIST_DIR}/embed-resources.sh" "${CMAKE_CURRENT_BINARY_DIR}"
DEPENDS
"${CMAKE_CURRENT_LIST_DIR}/embed-resources-cpp.index"
"${CMAKE_CURRENT_LIST_DIR}/embed-resources.index"
"${CMAKE_CURRENT_LIST_DIR}/embed-resources.sh"
"${CMAKE_CURRENT_LIST_DIR}/embed-resources.py"
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
COMMENT "Embedding resources...")
endif()
# this is the "object library" target: compiles the sources only once
add_library(objlib OBJECT ${OsmAndCore_ResourcesBundle_src})
# shared libraries need PIC
set_property(TARGET objlib PROPERTY POSITION_INDEPENDENT_CODE 1)
if (CMAKE_SHARED_LIBS_ALLOWED_ON_TARGET)
add_library(OsmAndCore_ResourcesBundle_shared SHARED $<TARGET_OBJECTS:objlib>)
#add_library(OsmAndCore_ResourcesBundle_shared SHARED ${OsmAndCore_ResourcesBundle_src})
endif()
if (CMAKE_STATIC_LIBS_ALLOWED_ON_TARGET)
add_library(OsmAndCore_ResourcesBundle_static STATIC $<TARGET_OBJECTS:objlib>)
#add_library(OsmAndCore_ResourcesBundle_static STATIC ${OsmAndCore_ResourcesBundle_src})
# if (CMAKE_COMPILER_FAMILY STREQUAL "msvc")
# target_link_libraries(OsmAndCore_ResourcesBundle_static
# LINK_PUBLIC
# "-INCLUDE:___CoreResourcesEmbeddedBundle__FakeReferences"
# )
# endif()
endif()
endif()