Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #
- # libbinrec: a recompiling translator for machine code
- # Copyright (c) 2016 Andrew Church <achurch@achurch.org>
- #
- # This software may be copied and redistributed under certain conditions;
- # see the file "COPYING" in the source code distribution for details.
- # NO WARRANTY is provided with this software.
- #
- # This CMake control file is intended for embedding libbinrec within other
- # programs; it may not be useful for installing a standalone copy of the
- # library.
- cmake_minimum_required(VERSION 2.8)
- include(CheckCCompilerFlag)
- set(BINREC_ENABLE_ASSERT TRUE CACHE BOOL "Enable basic assertion checks")
- set(BINREC_ENABLE_OPERAND_SANITY_CHECKS TRUE CACHE BOOL "Enable code generation assertion checks")
- set(BINREC_ENABLE_RTL_DEBUG_OPTIMIZE TRUE CACHE BOOL "Enable debug output from optimization passes")
- set(CMAKE_C_STANDARD 11)
- set(CMAKE_CXX_STANDARD 11)
- include_directories("${CMAKE_CURRENT_SOURCE_DIR}")
- file(GLOB SOURCES src/*.c src/*/*.c)
- add_library(binrec STATIC ${SOURCES})
- target_include_directories(binrec PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include")
- target_compile_definitions(binrec PRIVATE VERSION="0.1")
- target_compile_options(binrec PRIVATE -std=c99)
- if(BINREC_ENABLE_ASSERT)
- target_compile_definitions(binrec PRIVATE ENABLE_ASSERT)
- endif()
- if(BINREC_ENABLE_OPERAND_SANITY_CHECKS)
- target_compile_definitions(binrec PRIVATE ENABLE_OPERAND_SANITY_CHECKS)
- endif()
- if(BINREC_ENABLE_RTL_DEBUG_OPTIMIZE)
- target_compile_definitions(binrec PRIVATE RTL_DEBUG_OPTIMIZE)
- endif()
- add_library(testlib STATIC
- tests/common.c
- tests/common.h
- tests/execute.c
- tests/execute.h
- tests/log-capture.c
- tests/log-capture.h
- tests/mem-wrappers.c
- tests/mem-wrappers.h
- tests/ppc-lut.c
- tests/ppc-lut.h)
- enable_testing()
- file(GLOB TEST_SOURCES_SUB tests/*/*/*.c)
- foreach(test_src ${TEST_SOURCES_SUB})
- get_filename_component(test_name ${test_src} NAME_WE)
- get_filename_component(test_dir1 ${test_src} DIRECTORY)
- get_filename_component(test_dir1_name ${test_dir1} NAME)
- get_filename_component(test_dir2 ${test_dir1} DIRECTORY)
- get_filename_component(test_dir2_name ${test_dir2} NAME)
- set(test_target ${test_dir2_name}_${test_dir1_name}_${test_name})
- add_executable(${test_target} ${test_src})
- target_link_libraries(${test_target} binrec testlib)
- set_target_properties(${test_target} PROPERTIES
- RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/tests/${test_dir2_name}/${test_dir1_name}
- OUTPUT_NAME ${test_name})
- add_test(${test_target} ${CMAKE_BINARY_DIR}/tests/${test_dir2_name}/${test_dir1_name}/${test_name})
- endforeach()
- file(GLOB TEST_SOURCES_FULL tests/*/*.c tests/api/binrec++.cc)
- foreach(test_src ${TEST_SOURCES_FULL})
- get_filename_component(test_name ${test_src} NAME_WE)
- get_filename_component(test_dir1 ${test_src} DIRECTORY)
- get_filename_component(test_dir1_name ${test_dir1} NAME)
- set(test_target ${test_dir1_name}_${test_name})
- add_executable(${test_target} ${test_src})
- target_link_libraries(${test_target} binrec testlib)
- set_target_properties(${test_target} PROPERTIES
- RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/tests/${test_dir1_name}
- OUTPUT_NAME ${test_name})
- add_test(${test_target} ${CMAKE_BINARY_DIR}/tests/${test_dir1_name}/${test_name})
- endforeach()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement