Merge pull request #218 from saper/build-fixes
[envytools.git] / cgen / CMakeLists.txt
blob0cef4fe0ff1d0d8e2c4dd227e268be3e9a36d12c
1 project(ENVYTOOLS C)
2 cmake_minimum_required(VERSION 3.5)
4 set(CGEN_INCLUDE_DIR ${CMAKE_BINARY_DIR}/include-generated)
6 set(CGEN_ITEMS fb bus gpu)
7 set(CGEN_SOURCES "")
8 set(CGEN_HEADERS "")
10 foreach(ITEM ${CGEN_ITEMS})
11 add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/cgen/${ITEM}.c ${CGEN_INCLUDE_DIR}/cgen/${ITEM}.h
12                 COMMAND python3
13                 ARGS -m ssot.gen_c ssot.${ITEM} ${CMAKE_BINARY_DIR} ${CGEN_INCLUDE_DIR}
14                 MAIN_DEPENDENCY ../ssot/${ITEM}.py
15                 DEPENDS ../ssot/cgen.py ../ssot/gen_c.py
16                 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/..
18 set(CGEN_SOURCES ${CGEN_SOURCES} ${CMAKE_BINARY_DIR}/cgen/${ITEM}.c)
19 set(CGEN_HEADERS ${CGEN_HEADERS} ${CGEN_INCLUDE_DIR}/cgen/${ITEM}.h)
20 endforeach(ITEM)
22 add_library(cgen ${CGEN_SOURCES})
23 set_property(TARGET cgen PROPERTY POSITION_INDEPENDENT_CODE ON)