Commit 8113e5d7 authored by Julian Kranz's avatar Julian Kranz

Adapted CMake build files

parent adacc09b
......@@ -28,32 +28,43 @@ foreach(p LIB BIN INCLUDE CMAKE)
endif()
endforeach()
macro(frontend fend sources)
set(sources_merged ${sources} ${ARGN})
list(APPEND FRONTENDS ${fend})
add_custom_command(COMMAND gdsl_compiler --maxIter=42
--runtime=${CMAKE_CURRENT_SOURCE_DIR}/detail/codegen
--outname=gdsl_${fend}_rreil_frontend
${sources_merged}
OUTPUT gdsl_${fend}_rreil_frontend.c gdsl_${fend}_rreil_frontend.h
DEPENDS gdsl_compiler ${sources_merged}
file(GLOB_RECURSE MLTON_SOURCES
"detail/**.ml"
)
add_library(gdsl_${fend}_rreil gdsl_${fend}_rreil_frontend.c)
set_target_properties(gdsl_${fend}_rreil PROPERTIES COMPILE_FLAGS "-std=c11 -fPIC -m32")
target_include_directories(gdsl_${fend}_rreil PUBLIC
$<BUILD_INTERFACE: ${CMAKE_BINARY_DIR}/ arch/${fend}/>
$<INSTALL_INTERFACE:arch/${fend}/> $<INSTALL_INTERFACE:${INSTALL_BIN_DIR}> # <prefix>/include/
add_custom_command(COMMAND mlton -output ${CMAKE_BINARY_DIR}/gdslc ${CMAKE_SOURCE_DIR}/gdslc.mlb
OUTPUT gdslc
DEPENDS gdslc.mlb ${MLTON_SOURCES}
)
list(APPEND EXPORT_LIBRARIES gdsl_${fend}_rreil)
install(TARGETS gdsl_${fend}_rreil
# IMPORTANT: Add the library to the "export-set"
EXPORT gdslTargets
RUNTIME DESTINATION "${INSTALL_BIN_DIR}" COMPONENT bin
LIBRARY DESTINATION "${INSTALL_LIB_DIR}" COMPONENT lib
ARCHIVE DESTINATION "${INSTALL_LIB_DIR}" COMPONENT lib
PUBLIC_HEADER DESTINATION "${INSTALL_INCLUDE_DIR}/"
COMPONENT dev)
macro(frontend fend sources)
set(sources_merged ${sources} ${ARGN})
list(APPEND FRONTENDS ${fend})
add_custom_command(COMMAND ./gdslc --maxIter=42
--runtime=${CMAKE_CURRENT_SOURCE_DIR}/detail/codegen
--outname=gdsl-${fend}-rreil
${sources_merged}
OUTPUT gdsl-${fend}-rreil.c gdsl-${fend}-rreil.h
DEPENDS ${CMAKE_BINARY_DIR}/gdslc ${sources_merged}
)
add_library(gdsl_${fend}_rreil gdsl-${fend}-rreil.c)
set_target_properties(gdsl_${fend}_rreil PROPERTIES COMPILE_FLAGS "-std=c11 -fPIC")
target_include_directories(gdsl_${fend}_rreil PUBLIC
$<BUILD_INTERFACE: ${CMAKE_BINARY_DIR}/ arch/${fend}/>
$<INSTALL_INTERFACE:arch/${fend}/> $<INSTALL_INTERFACE:${INSTALL_BIN_DIR}> # <prefix>/include/
)
string(TOUPPER ${fend} FEND)
target_compile_definitions(gdsl_${fend}_rreil PUBLIC "USE_${FEND}_RREIL")
list(APPEND EXPORT_LIBRARIES gdsl_${fend}_rreil)
install(TARGETS gdsl_${fend}_rreil
# IMPORTANT: Add the library to the "export-set"
EXPORT gdslTargets
RUNTIME DESTINATION "${INSTALL_BIN_DIR}" COMPONENT bin
LIBRARY DESTINATION "${INSTALL_LIB_DIR}" COMPONENT lib
ARCHIVE DESTINATION "${INSTALL_LIB_DIR}" COMPONENT lib
PUBLIC_HEADER DESTINATION "${INSTALL_INCLUDE_DIR}/"
COMPONENT dev)
endmacro(frontend)
set(GDSL_DIR ${CMAKE_CURRENT_SOURCE_DIR}/specifications)
......@@ -136,7 +147,6 @@ frontend(mips ${FRONTEND_SRCS_COMMON}
${GDSL_DIR}/mips/mips-traverse_r6.ml
)
add_subdirectory(gdslc)
add_subdirectory(libs)
add_subdirectory(tools)
......
......@@ -13,6 +13,8 @@
#include "gdsl-mips.h"
#elif USE_MIPS_RREIL
#include "gdsl-mips-rreil.h"
#elif USE_ARM7_RREIL
#include "gdsl-arm7-rreil.h"
#endif
../gdsl_manual.h
\ No newline at end of file
cmake_minimum_required (VERSION 2.8)
project (gdsl-libs)
add_subdirectory(multiplex_stub)
add_subdirectory(gdsl-multiplex)
add_subdirectory(cppgdsl)
add_subdirectory(readhex)
add_subdirectory(gdutil)
......
......@@ -12,27 +12,27 @@ file(GLOB_RECURSE SOURCES
#set_property(TARGET cppgdsl PROPERTY CXX_STANDARD 11)
macro(cppgdsl fend)
add_library(cppgdsl_${fend} ${SOURCES})
set_target_properties(cppgdsl_${fend} PROPERTIES COMPILE_FLAGS "-fPIC -std=c++11 -m32")
target_include_directories(cppgdsl_${fend} PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include/>
$<INSTALL_INTERFACE:include/> # <prefix>/include/
)
target_link_libraries(cppgdsl_${fend} multiplex_stub_${fend})
list(APPEND EXPORT_LIBRARIES cppgdsl_${fend})
install(TARGETS cppgdsl_${fend}
# IMPORTANT: Add the library to the "export-set"
EXPORT gdslTargets
RUNTIME DESTINATION "${INSTALL_BIN_DIR}" COMPONENT bin
LIBRARY DESTINATION "${INSTALL_LIB_DIR}" COMPONENT lib
ARCHIVE DESTINATION "${INSTALL_LIB_DIR}" COMPONENT lib
PUBLIC_HEADER DESTINATION "${INSTALL_INCLUDE_DIR}/"
COMPONENT dev)
add_library(cppgdsl_${fend} ${SOURCES})
set_target_properties(cppgdsl_${fend} PROPERTIES COMPILE_FLAGS "-fPIC -std=c++11")
target_include_directories(cppgdsl_${fend} PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include/>
$<INSTALL_INTERFACE:include/> # <prefix>/include/
)
target_link_libraries(cppgdsl_${fend} multiplex_${fend})
list(APPEND EXPORT_LIBRARIES cppgdsl_${fend})
install(TARGETS cppgdsl_${fend}
# IMPORTANT: Add the library to the "export-set"
EXPORT gdslTargets
RUNTIME DESTINATION "${INSTALL_BIN_DIR}" COMPONENT bin
LIBRARY DESTINATION "${INSTALL_LIB_DIR}" COMPONENT lib
ARCHIVE DESTINATION "${INSTALL_LIB_DIR}" COMPONENT lib
PUBLIC_HEADER DESTINATION "${INSTALL_INCLUDE_DIR}/"
COMPONENT dev)
endmacro(cppgdsl)
foreach(fend ${FRONTENDS})
cppgdsl(${fend})
cppgdsl(${fend})
endforeach(fend)
set (EXPORT_LIBRARIES ${EXPORT_LIBRARIES} PARENT_SCOPE)
cmake_minimum_required (VERSION 2.8)
project (multiplex)
file(GLOB_RECURSE SOURCES
"src/**.c"
)
macro(multiplex fend)
add_library(multiplex_${fend} ${SOURCES})
target_include_directories(multiplex_${fend} PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include/>
$<INSTALL_INTERFACE:include/> # <prefix>/include/
)
set_target_properties(multiplex_${fend} PROPERTIES COMPILE_FLAGS "-std=c11")
target_link_libraries(multiplex_${fend} dl)
list(APPEND EXPORT_LIBRARIES multiplex_${fend})
install(TARGETS multiplex_${fend}
# IMPORTANT: Add the library to the "export-set"
EXPORT gdslTargets
RUNTIME DESTINATION "${INSTALL_BIN_DIR}" COMPONENT bin
LIBRARY DESTINATION "${INSTALL_LIB_DIR}" COMPONENT lib
ARCHIVE DESTINATION "${INSTALL_LIB_DIR}" COMPONENT lib
PUBLIC_HEADER DESTINATION "${INSTALL_INCLUDE_DIR}/"
COMPONENT dev)
endmacro(multiplex)
foreach(fend ${FRONTENDS})
multiplex(${fend})
endforeach(fend)
set (EXPORT_LIBRARIES ${EXPORT_LIBRARIES} PARENT_SCOPE)
......@@ -5,13 +5,27 @@ file(GLOB_RECURSE SOURCES
"src/**.c"
)
function(gdutil fend)
macro(gdutil fend)
add_library(gdutil_${fend} ${SOURCES})
target_include_directories(gdutil_${fend} PUBLIC include/)
set_target_properties(gdutil_${fend} PROPERTIES COMPILE_FLAGS "-std=c11 -m32")
target_link_libraries(gdutil_${fend} multiplex_stub_${fend})
endfunction(gdutil)
target_include_directories(gdutil_${fend} PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include/>
$<INSTALL_INTERFACE:include/> # <prefix>/include/
)
set_target_properties(gdutil_${fend} PROPERTIES COMPILE_FLAGS "-std=c11")
list(APPEND EXPORT_LIBRARIES gdutil_${fend})
install(TARGETS gdutil_${fend}
# IMPORTANT: Add the library to the "export-set"
EXPORT gdslTargets
RUNTIME DESTINATION "${INSTALL_BIN_DIR}" COMPONENT bin
LIBRARY DESTINATION "${INSTALL_LIB_DIR}" COMPONENT lib
ARCHIVE DESTINATION "${INSTALL_LIB_DIR}" COMPONENT lib
PUBLIC_HEADER DESTINATION "${INSTALL_INCLUDE_DIR}/"
COMPONENT dev)
endmacro(gdutil)
foreach(fend ${FRONTENDS})
gdutil(${fend})
endforeach(fend)
set (EXPORT_LIBRARIES ${EXPORT_LIBRARIES} PARENT_SCOPE)
......@@ -6,7 +6,7 @@ file(GLOB_RECURSE SOURCES
)
add_library(readhex ${SOURCES})
set_target_properties(readhex PROPERTIES COMPILE_FLAGS "-std=c11 -m32")
set_target_properties(readhex PROPERTIES COMPILE_FLAGS "-std=c11")
target_include_directories(readhex PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include/>
$<INSTALL_INTERFACE:include/> # <prefix>/include/
......
......@@ -6,37 +6,41 @@ project (gdsl-tools)
#set_property(TARGET cppgdsl PROPERTY CXX_STANDARD 11)
function(semantics_cli fend)
string(TOUPPER ${fend} FEND)
add_executable(semantics_cli_${fend} semantics-cli.c)
set_target_properties(semantics_cli_${fend} PROPERTIES COMPILE_FLAGS "-std=c11 -m32")
set_target_properties(semantics_cli_${fend} PROPERTIES LINK_FLAGS "-m32")
target_link_libraries(semantics_cli_${fend} readhex gdutil_${fend})
set_target_properties(semantics_cli_${fend} PROPERTIES COMPILE_FLAGS "-std=c11")
set_target_properties(semantics_cli_${fend} PROPERTIES LINK_FLAGS "")
target_link_libraries(semantics_cli_${fend} gdsl_${fend}_rreil readhex gdutil_${fend})
endfunction(semantics_cli)
function(decoder_cli fend)
string(TOUPPER ${fend} FEND)
add_executable(decoder_cli_${fend} decoder-cli.c)
set_target_properties(decoder_cli_${fend} PROPERTIES COMPILE_FLAGS "-std=c11 -m32")
set_target_properties(decoder_cli_${fend} PROPERTIES LINK_FLAGS "-m32")
target_link_libraries(decoder_cli_${fend} readhex gdutil_${fend})
set_target_properties(decoder_cli_${fend} PROPERTIES COMPILE_FLAGS "-std=c11")
set_target_properties(decoder_cli_${fend} PROPERTIES LINK_FLAGS "")
target_link_libraries(decoder_cli_${fend} gdsl_${fend}_rreil readhex gdutil_${fend})
endfunction(decoder_cli)
function(semantics_opt fend)
string(TOUPPER ${fend} FEND)
add_executable(semantics_opt_${fend} semantics-opt.c)
set_target_properties(semantics_opt_${fend} PROPERTIES COMPILE_FLAGS "-std=c11 -m32")
set_target_properties(semantics_opt_${fend} PROPERTIES LINK_FLAGS "-m32")
target_link_libraries(semantics_opt_${fend} multiplex_stub_${fend} gdutil_${fend} elf)
set_target_properties(semantics_opt_${fend} PROPERTIES COMPILE_FLAGS "-std=c11")
set_target_properties(semantics_opt_${fend} PROPERTIES LINK_FLAGS "")
target_link_libraries(semantics_opt_${fend} gdsl_${fend}_rreil gdutil_${fend} elf)
endfunction(semantics_opt)
function(semantics_cif_cli fend)
string(TOUPPER ${fend} FEND)
add_executable(semantics_cif_cli_${fend} semantics-cif-cli.c)
set_target_properties(semantics_cif_cli_${fend} PROPERTIES COMPILE_FLAGS "-std=c11 -m32")
set_target_properties(semantics_cif_cli_${fend} PROPERTIES LINK_FLAGS "-m32")
target_link_libraries(semantics_cif_cli_${fend} multiplex_stub_${fend} gdutil_${fend} readhex)
set_target_properties(semantics_cif_cli_${fend} PROPERTIES COMPILE_FLAGS "-std=c11")
set_target_properties(semantics_cif_cli_${fend} PROPERTIES LINK_FLAGS "")
target_link_libraries(semantics_cif_cli_${fend} gdsl_${fend}_rreil gdutil_${fend} readhex)
endfunction(semantics_cif_cli)
function(cppgdsl_demo fend)
add_executable(cppgdsl_demo_${fend} cppgdsl-demo.cpp)
set_target_properties(cppgdsl_demo_${fend} PROPERTIES COMPILE_FLAGS "-std=c++11 -m32")
set_target_properties(cppgdsl_demo_${fend} PROPERTIES LINK_FLAGS "-m32")
set_target_properties(cppgdsl_demo_${fend} PROPERTIES COMPILE_FLAGS "-std=c++11")
set_target_properties(cppgdsl_demo_${fend} PROPERTIES LINK_FLAGS "")
target_link_libraries(cppgdsl_demo_${fend} cppgdsl_${fend})
endfunction(cppgdsl_demo)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment