|
| 1 | +cmake_minimum_required(VERSION 3.11) |
| 2 | + |
| 3 | +## Specify the top level name of the project - this will define the solution name for Visual Studio |
| 4 | +project(RMV) |
| 5 | + |
| 6 | +## For RMV we only care about the Debug and Release configuration types |
| 7 | +set(CMAKE_CONFIGURATION_TYPES Debug Release) |
| 8 | + |
| 9 | +## Determine build suffixes based on configuration, bitness and internal status |
| 10 | +## These values will be inherited by all child projects |
| 11 | +set(ADT_PLATFORM_POSTFIX "-x86") |
| 12 | +IF(CMAKE_SIZEOF_VOID_P EQUAL 8) |
| 13 | + set(ADT_PLATFORM_POSTFIX "-x64") |
| 14 | +ENDIF() |
| 15 | + |
| 16 | +# As default for RMV, include the debug & internal status in filename - but not the platform bitness |
| 17 | +set (CMAKE_DEBUG_POSTFIX -d${ADT_INTERNAL_POSTFIX}) |
| 18 | +set (CMAKE_RELEASE_POSTFIX ${ADT_INTERNAL_POSTFIX}) |
| 19 | + |
| 20 | +IF(WIN32) |
| 21 | + set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/../release${ADT_INTERNAL_POSTFIX}) |
| 22 | + set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/../debug${ADT_INTERNAL_POSTFIX}) |
| 23 | +ELSE(WIN32) |
| 24 | + set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/../../release${ADT_INTERNAL_POSTFIX}) |
| 25 | + set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/../../debug${ADT_INTERNAL_POSTFIX}) |
| 26 | +ENDIF(WIN32) |
| 27 | + |
| 28 | +# Add for CentOS compiler warning |
| 29 | +add_definitions(-DJSON_SKIP_UNSUPPORTED_COMPILER_CHECK) |
| 30 | + |
| 31 | +include_directories("${PROJECT_SOURCE_DIR}/external/qt_common/") |
| 32 | +include_directories("${PROJECT_SOURCE_DIR}/external/") |
| 33 | + |
| 34 | +# Global compiler options |
| 35 | +IF(WIN32) |
| 36 | + add_compile_options(/W4 /WX /MP) |
| 37 | + # disable warning C4201: nonstandard extension used: nameless struct/union |
| 38 | + add_compile_options(/wd4201) |
| 39 | + # this warning is caused by the QT header files - use pragma to disable at source |
| 40 | + # disable warning C4127: conditional expression is constant |
| 41 | + add_compile_options(/wd4127) |
| 42 | + # bump the stack size |
| 43 | + add_link_options(/STACK:16777216) |
| 44 | +ELSEIF(UNIX) |
| 45 | + # Use -Wno-missing-field-initializers for CentOS compiler warning |
| 46 | + add_compile_options(-std=c++11 -D_LINUX -Wall -Wextra -Werror -Wno-missing-field-initializers) |
| 47 | + # Use _DEBUG on Unix for Debug Builds (defined automatically on Windows) |
| 48 | + set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_DEBUG") |
| 49 | +ENDIF(WIN32) |
| 50 | + |
| 51 | +IF(WIN32) |
| 52 | + set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Zi") |
| 53 | + set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /DEBUG") |
| 54 | +ENDIF(WIN32) |
| 55 | + |
| 56 | +# Macro to build source groups to match directory structure |
| 57 | +MACRO(SOURCE_GROUP_BY_FOLDER target) |
| 58 | + SET(SOURCE_GROUP_DELIMITER "/") |
| 59 | + SET(last_dir "") |
| 60 | + SET(files "") |
| 61 | + FOREACH(file ${SOURCES}) |
| 62 | + GET_FILENAME_COMPONENT(dir "${file}" PATH) |
| 63 | + IF (NOT "${dir}" STREQUAL "${last_dir}") |
| 64 | + IF (files) |
| 65 | + SOURCE_GROUP("${last_dir}" FILES ${files}) |
| 66 | + ENDIF (files) |
| 67 | + SET(files "") |
| 68 | + ENDIF (NOT "${dir}" STREQUAL "${last_dir}") |
| 69 | + SET(files ${files} ${file}) |
| 70 | + SET(last_dir "${dir}") |
| 71 | + ENDFOREACH(file) |
| 72 | + IF (files) |
| 73 | + SOURCE_GROUP("${last_dir}" FILES ${files}) |
| 74 | + ENDIF (files) |
| 75 | +ENDMACRO(SOURCE_GROUP_BY_FOLDER) |
| 76 | + |
| 77 | +add_subdirectory(external/qt_common/custom_widgets QtCommon/custom_widgets) |
| 78 | +add_subdirectory(external/qt_common/utils QtCommon/utils) |
| 79 | +add_subdirectory(source/parser parser) |
| 80 | +add_subdirectory(source/backend backend) |
| 81 | +add_subdirectory(source/frontend frontend) |
| 82 | + |
| 83 | +# Group external dependency targets into folder |
| 84 | +IF(WIN32) |
| 85 | +set_property(GLOBAL PROPERTY USE_FOLDERS ON) |
| 86 | +set_target_properties(QtCustomWidgets |
| 87 | + QtUtils |
| 88 | + PROPERTIES |
| 89 | + FOLDER Dependencies |
| 90 | +) |
| 91 | +ELSEIF(APPLE) |
| 92 | +set_property(GLOBAL PROPERTY USE_FOLDERS ON) |
| 93 | +set_target_properties(QtCustomWidgets |
| 94 | + QtUtils |
| 95 | + PROPERTIES |
| 96 | + FOLDER Dependencies |
| 97 | +) |
| 98 | +ENDIF() |
| 99 | + |
| 100 | +IF(WIN32) |
| 101 | + set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT RadeonMemoryVisualizer) |
| 102 | +ENDIF(WIN32) |
| 103 | + |
| 104 | +## Copy Documentation and Samples to output directory |
| 105 | +add_custom_target(Documentation ALL) |
| 106 | +add_custom_command(TARGET Documentation POST_BUILD |
| 107 | + COMMAND ${CMAKE_COMMAND} -E echo "copying documentation to output directory" |
| 108 | + COMMAND ${CMAKE_COMMAND} -E make_directory $<TARGET_FILE_DIR:RadeonMemoryVisualizer>/docs |
| 109 | + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_SOURCE_DIR}/documentation/License.htm $<TARGET_FILE_DIR:RadeonMemoryVisualizer>/docs/. |
| 110 | + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_SOURCE_DIR}/README.md $<TARGET_FILE_DIR:RadeonMemoryVisualizer>/. |
| 111 | + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_SOURCE_DIR}/Release_Notes.txt $<TARGET_FILE_DIR:RadeonMemoryVisualizer>/. |
| 112 | + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_SOURCE_DIR}/NOTICES.txt $<TARGET_FILE_DIR:RadeonMemoryVisualizer>/. |
| 113 | + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_SOURCE_DIR}/License.txt $<TARGET_FILE_DIR:RadeonMemoryVisualizer>/. |
| 114 | + COMMAND ${CMAKE_COMMAND} -E echo "copying samples to output directory" |
| 115 | + COMMAND ${CMAKE_COMMAND} -E make_directory $<TARGET_FILE_DIR:RadeonMemoryVisualizer>/samples |
| 116 | + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_SOURCE_DIR}/samples/sampleTrace.rmv $<TARGET_FILE_DIR:RadeonMemoryVisualizer>/samples/. |
| 117 | +) |
0 commit comments