CMakeLists.txt 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  1. cmake_minimum_required(VERSION 3.18)
  2. project (WithDefs HIP)
  3. set(CMAKE_HIP_ARCHITECTURES OFF)
  4. set(release_compile_defs DEFREL)
  5. #Goal for this example:
  6. #build a executable that needs to be passed a complex define through add_definitions
  7. #this verifies we can pass C++ style attributes to hipcc
  8. add_definitions("-DPACKED_DEFINE=[[gnu::packed]]")
  9. add_executable(HIPOnlyWithDefs main.hip.cpp)
  10. set_source_files_properties(main.hip.cpp PROPERTIES LANGUAGE HIP)
  11. target_compile_features(HIPOnlyWithDefs PRIVATE hip_std_17)
  12. target_compile_options(HIPOnlyWithDefs
  13. PRIVATE
  14. -DFLAG_COMPILE_LANG_$<COMPILE_LANGUAGE>
  15. $<$<HIP_COMPILER_ID:ROCMClang>:-DFLAG_LANG_IS_HIP=$<COMPILE_LANGUAGE:HIP>> # Host-only defines are possible only on NVCC.
  16. )
  17. target_compile_definitions(HIPOnlyWithDefs
  18. PRIVATE
  19. $<$<CONFIG:RELEASE>:$<BUILD_INTERFACE:${release_compile_defs}>>
  20. -DDEF_COMPILE_LANG_$<COMPILE_LANGUAGE>
  21. -DDEF_LANG_IS_HIP=$<COMPILE_LANGUAGE:HIP>
  22. -DDEF_HIP_COMPILER=$<HIP_COMPILER_ID>
  23. -DDEF_HIP_COMPILER_VERSION=$<HIP_COMPILER_VERSION>
  24. )
  25. target_include_directories(HIPOnlyWithDefs
  26. PRIVATE
  27. $<$<COMPILE_LANGUAGE:HIP>:${CMAKE_CURRENT_SOURCE_DIR}/inc_hip>
  28. )