summaryrefslogtreecommitdiff
path: root/CMakeLists.txt
blob: ad953343f02f3e9578e624f59576ab9e4ae501d2 (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
project(eynote)
cmake_minimum_required(VERSION 2.8)

aux_source_directory(. SRC_LIST)
aux_source_directory(lib SRC_LIST)

add_executable(${PROJECT_NAME} ${SRC_LIST})

# Define the libs here.
set(Libs Eo Efl Eina Eet Evas Ecore Edje Efreet Elementary Emotion Emile)

# Add your own CFLAGS here.
add_definitions(-DEFL_EO_API_SUPPORT=1 -DEFL_BETA_API_SUPPORT=1)

# Folders
set(edcdir data/edc)
set(edcimages data/images)

execute_process(COMMAND pkg-config --variable=backgrounds enlightenment OUTPUT_VARIABLE ebg)
string(STRIP ${ebg} ebg)
add_definitions(-DE_BG_ROOT=\"${ebg}\")

include_directories(. lib data/edc ${CMAKE_BINARY_DIR}/eodir/lib)
target_link_libraries(${PROJECT_NAME} pthread m)

set(eoflags -I. -I${CMAKE_CURRENT_SOURCE_DIR}/lib)
foreach(Lib ${Libs})
  string(TOLOWER ${Lib} lib)
  string(TOUPPER ${Lib} LIB)
  find_package(${Lib} REQUIRED)
  set(thisinc ${${LIB}_INCLUDE_DIRS})
  include_directories(${thisinc})
  set(thislib ${${LIB}_LIBRARIES})
  #set(libraries ${libraries} ${thislib})
  target_link_libraries(${PROJECT_NAME} ${thislib})
  execute_process(COMMAND pkg-config --variable=eolian_flags ${lib} OUTPUT_VARIABLE eof)
  string(STRIP ${eof} eof)
  set(eoflags ${eoflags} ${eof})
endforeach(Lib)

add_definitions(-Wall -Wextra)

# Disable -rpath as it will skip LD_LIBRARY_PATH. Very inconvenient for debug :)
set(CMAKE_SKIP_BUILD_RPATH TRUE)

# Make this program runnable by QuickLaunch
add_definitions(-fpie -std=gnu99)

if (NOT WINDOWS)
  set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS -pie)
endif (NOT WINDOWS)

# Copy image files
file(GLOB allimages images/*.*g)
foreach(img ${allimages})
  configure_file(${img} . COPYONLY)
endforeach(img)

# Compile edc files
#file(GLOB alledc ${edcdir}/*.edc)
set(alledc ${CMAKE_CURRENT_SOURCE_DIR}/${edcdir}/default.edc)
file(GLOB alledx ${edcdir}/*.edc)
foreach(edc ${alledc})
  string(REPLACE ${CMAKE_CURRENT_SOURCE_DIR}/${edcdir} "." out ${edc})
  string(REPLACE edc edj out ${out})
  add_custom_command(
    OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${out}
    COMMAND edje_cc ${edc} -id ${CMAKE_CURRENT_SOURCE_DIR}/${edcimages} -o ${CMAKE_CURRENT_BINARY_DIR}/${out}
    DEPENDS ${edc} ${alledx}
    COMMENT "Compiling EDC: ${out}"
    VERBATIM)
  get_filename_component(tgt ${edc} NAME)
  add_custom_target(compile_${tgt} ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${out})
endforeach(edc)

# Create folder for eolian output files
add_custom_command(OUTPUT eodir/lib COMMAND mkdir -p ${CMAKE_BINARY_DIR}/eodir/lib)

# Run Eolian
file(GLOB alleot *.eot lib/*.eot)
foreach(eot ${alleot})
  string(REPLACE eot eo.h eoh ${eot})
  string(REPLACE ${CMAKE_CURRENT_SOURCE_DIR}/ "" eoh ${eoh})
  add_custom_command(
    OUTPUT eodir/${eoh}
    COMMAND eolian_gen --eo ${eoflags} --gh -o eodir/${eoh} ${eot}
    DEPENDS ${eot} eodir/lib
    COMMENT "EOLIAN EO.T: ${eot}"
    VERBATIM)
  get_filename_component(tgt ${eot} NAME)
  add_custom_target(compile_${tgt} ALL DEPENDS eodir/${eoh})
endforeach(eot)

file(GLOB alleo *.eo lib/*.eo)
foreach(eo ${alleo})
  # Implementation files
  string(REPLACE eo c eoimpl ${eo})
  add_custom_command(
    OUTPUT ${eoimpl}
    COMMAND eolian_gen --eo ${eoflags} --gi -o ${eoimpl} ${eo}
    DEPENDS ${eo} ${alleot}
    COMMENT "EOLIAN .C: ${eoimpl}"
    VERBATIM)
  get_filename_component(tgt ${eoimpl} NAME)
  add_custom_target(compile_${tgt} ALL DEPENDS ${eoimpl})

  # .eo.c files
  string(REPLACE eo eo.c eox ${eo})
  string(REPLACE ${CMAKE_CURRENT_SOURCE_DIR}/ "" eox ${eox})
  add_custom_command(
    OUTPUT eodir/${eox}
    COMMAND eolian_gen --eo ${eoflags} --gc -o eodir/${eox} ${eo}
    DEPENDS ${eo} ${alleot} eodir/lib
    COMMENT "EOLIAN EO.C: ${eox}"
    VERBATIM)
  get_filename_component(tgt ${eox} NAME)
  add_custom_target(compile_${tgt} ALL DEPENDS eodir/${eox})

  # Headers
  string(REPLACE eo eo.h eoh ${eo})
  string(REPLACE ${CMAKE_CURRENT_SOURCE_DIR}/ "" eoh ${eoh})
  add_custom_command(
    OUTPUT eodir/${eoh}
    COMMAND eolian_gen --eo ${eoflags} --gh -o eodir/${eoh} ${eo}
    DEPENDS ${eo} ${alleot} eodir/lib
    COMMENT "EOLIAN EO.H: ${eoh}"
    VERBATIM)
  get_filename_component(tgt ${eoh} NAME)
  add_custom_target(compile_${tgt} ALL DEPENDS eodir/${eoh})
endforeach(eo)

install(TARGETS ${PROJECT_NAME} DESTINATION bin)