Advertisement
Guest User

Untitled

a guest
Mar 28th, 2017
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.21 KB | None | 0 0
  1. #
  2. # libbinrec: a recompiling translator for machine code
  3. # Copyright (c) 2016 Andrew Church <achurch@achurch.org>
  4. #
  5. # This software may be copied and redistributed under certain conditions;
  6. # see the file "COPYING" in the source code distribution for details.
  7. # NO WARRANTY is provided with this software.
  8. #
  9.  
  10. # This CMake control file is intended for embedding libbinrec within other
  11. # programs; it may not be useful for installing a standalone copy of the
  12. # library.
  13.  
  14. cmake_minimum_required(VERSION 2.8)
  15. include(CheckCCompilerFlag)
  16.  
  17. set(BINREC_ENABLE_ASSERT TRUE CACHE BOOL "Enable basic assertion checks")
  18. set(BINREC_ENABLE_OPERAND_SANITY_CHECKS TRUE CACHE BOOL "Enable code generation assertion checks")
  19. set(BINREC_ENABLE_RTL_DEBUG_OPTIMIZE TRUE CACHE BOOL "Enable debug output from optimization passes")
  20. set(CMAKE_C_STANDARD 11)
  21. set(CMAKE_CXX_STANDARD 11)
  22.  
  23. include_directories("${CMAKE_CURRENT_SOURCE_DIR}")
  24. file(GLOB SOURCES src/*.c src/*/*.c)
  25. add_library(binrec STATIC ${SOURCES})
  26.  
  27. target_include_directories(binrec PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include")
  28. target_compile_definitions(binrec PRIVATE VERSION="0.1")
  29. target_compile_options(binrec PRIVATE -std=c99)
  30. if(BINREC_ENABLE_ASSERT)
  31. target_compile_definitions(binrec PRIVATE ENABLE_ASSERT)
  32. endif()
  33. if(BINREC_ENABLE_OPERAND_SANITY_CHECKS)
  34. target_compile_definitions(binrec PRIVATE ENABLE_OPERAND_SANITY_CHECKS)
  35. endif()
  36. if(BINREC_ENABLE_RTL_DEBUG_OPTIMIZE)
  37. target_compile_definitions(binrec PRIVATE RTL_DEBUG_OPTIMIZE)
  38. endif()
  39.  
  40. add_library(testlib STATIC
  41. tests/common.c
  42. tests/common.h
  43. tests/execute.c
  44. tests/execute.h
  45. tests/log-capture.c
  46. tests/log-capture.h
  47. tests/mem-wrappers.c
  48. tests/mem-wrappers.h
  49. tests/ppc-lut.c
  50. tests/ppc-lut.h)
  51.  
  52. enable_testing()
  53.  
  54. file(GLOB TEST_SOURCES_SUB tests/*/*/*.c)
  55. foreach(test_src ${TEST_SOURCES_SUB})
  56. get_filename_component(test_name ${test_src} NAME_WE)
  57. get_filename_component(test_dir1 ${test_src} DIRECTORY)
  58. get_filename_component(test_dir1_name ${test_dir1} NAME)
  59. get_filename_component(test_dir2 ${test_dir1} DIRECTORY)
  60. get_filename_component(test_dir2_name ${test_dir2} NAME)
  61. set(test_target ${test_dir2_name}_${test_dir1_name}_${test_name})
  62. add_executable(${test_target} ${test_src})
  63. target_link_libraries(${test_target} binrec testlib)
  64. set_target_properties(${test_target} PROPERTIES
  65. RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/tests/${test_dir2_name}/${test_dir1_name}
  66. OUTPUT_NAME ${test_name})
  67. add_test(${test_target} ${CMAKE_BINARY_DIR}/tests/${test_dir2_name}/${test_dir1_name}/${test_name})
  68. endforeach()
  69.  
  70. file(GLOB TEST_SOURCES_FULL tests/*/*.c tests/api/binrec++.cc)
  71. foreach(test_src ${TEST_SOURCES_FULL})
  72. get_filename_component(test_name ${test_src} NAME_WE)
  73. get_filename_component(test_dir1 ${test_src} DIRECTORY)
  74. get_filename_component(test_dir1_name ${test_dir1} NAME)
  75. set(test_target ${test_dir1_name}_${test_name})
  76. add_executable(${test_target} ${test_src})
  77. target_link_libraries(${test_target} binrec testlib)
  78. set_target_properties(${test_target} PROPERTIES
  79. RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/tests/${test_dir1_name}
  80. OUTPUT_NAME ${test_name})
  81. add_test(${test_target} ${CMAKE_BINARY_DIR}/tests/${test_dir1_name}/${test_name})
  82. endforeach()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement