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