From 7383eac88a3fb5a268c7a26f9f41ea76f4164036 Mon Sep 17 00:00:00 2001 From: Jorg Doku Date: Wed, 11 Jul 2018 16:13:07 -0400 Subject: [PATCH 1/5] Support INCLUDE_DIRECTORIES & COMPILE_DEFINITIONS --- hipamd/cmake/FindHIP.cmake | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/hipamd/cmake/FindHIP.cmake b/hipamd/cmake/FindHIP.cmake index b761356c9a..1a5a8ca4b8 100644 --- a/hipamd/cmake/FindHIP.cmake +++ b/hipamd/cmake/FindHIP.cmake @@ -23,6 +23,26 @@ option(HIP_HOST_COMPILATION_CPP "Host code compilation mode" ON) option(HIP_VERBOSE_BUILD "Print out the commands run while compiling the HIP source file. With the Makefile generator this defaults to VERBOSE variable specified on the command line, but can be forced on with this option." OFF) mark_as_advanced(HIP_HOST_COMPILATION_CPP) +############################################################################### +# Set HIP CMAKE Flags +############################################################################### +# Copy the invocation styles from CXX to HIP +set(CMAKE_HIP_ARCHIVE_CREATE ${CMAKE_CXX_ARCHIVE_CREATE}) +set(CMAKE_HIP_ARCHIVE_FINISH ${CMAKE_CXX_ARCHIVE_FINISH}) +set(CMAKE_SHARED_LIBRARY_SONAME_HIP_FLAG ${CMAKE_SHARED_LIBRARY_SONAME_CXX_FLAG}) +set(CMAKE_SHARED_LIBRARY_CREATE_HIP_FLAGS ${CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS}) +set(CMAKE_SHARED_LIBRARY_HIP_FLAGS ${CMAKE_SHARED_LIBRARY_CXX_FLAGS}) +set(CMAKE_SHARED_LIBRARY_LINK_HIP_FLAGS ${CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS}) +set(CMAKE_SHARED_LIBRARY_RUNTIME_HIP_FLAG ${CMAKE_SHARED_LIBRARY_RUNTIME_CXX_FLAG}) +set(CMAKE_SHARED_LIBRARY_RUNTIME_HIP_FLAG_SEP ${CMAKE_SHARED_LIBRARY_RUNTIME_CXX_FLAG_SEP}) +set(CMAKE_SHARED_LIBRARY_LINK_STATIC_HIP_FLAGS ${CMAKE_SHARED_LIBRARY_LINK_STATIC_CXX_FLAGS}) +set(CMAKE_SHARED_LIBRARY_LINK_DYNAMIC_HIP_FLAGS ${CMAKE_SHARED_LIBRARY_LINK_DYNAMIC_CXX_FLAGS}) + +# Set the CMake Flags to use the HCC Compilier. +set(CMAKE_HIP_CREATE_SHARED_LIBRARY "${HIP_HIPCC_CMAKE_LINKER_HELPER} ${HCC_PATH} -o ") +set(CMAKE_HIP_CREATE_SHARED_MODULE "${HIP_HIPCC_CMAKE_LINKER_HELPER} ${HCC_PATH} -o -shared" ) +set(CMAKE_HIP_LINK_EXECUTABLE "${HIP_HIPCC_CMAKE_LINKER_HELPER} ${HCC_PATH} -o ") + ############################################################################### # FIND: HIP and associated helper binaries ############################################################################### @@ -383,6 +403,10 @@ macro(HIP_PREPARE_TARGET_COMMANDS _target _format _generated_files _source_files HIP_PARSE_HIPCC_OPTIONS(HIP_HCC_FLAGS ${_hcc_options}) HIP_PARSE_HIPCC_OPTIONS(HIP_NVCC_FLAGS ${_nvcc_options}) + # Add the include directories && compile definitions + list(APPEND HIP_HIPCC_INCLUDE_ARGS_USER "-I$, -I>") + list(APPEND HIP_HIPCC_FLAGS "-D$, -D>") + # Check if we are building shared library. set(_hip_build_shared_libs FALSE) list(FIND _hip_cmake_options SHARED _hip_found_SHARED) @@ -478,7 +502,7 @@ macro(HIP_PREPARE_TARGET_COMMANDS _target _format _generated_files _source_files set(verbose_output ON) else() set(verbose_output OFF) - endif() + endif() # Create up the comment string file(RELATIVE_PATH generated_file_relative_path "${CMAKE_BINARY_DIR}" "${generated_file}") From a484f89b34b51f460793116912197c5e7ba09318 Mon Sep 17 00:00:00 2001 From: Jorghi12 Date: Thu, 12 Jul 2018 13:56:08 -0400 Subject: [PATCH 2/5] Update FindHIP.cmake Updating placement. --- hipamd/cmake/FindHIP.cmake | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/hipamd/cmake/FindHIP.cmake b/hipamd/cmake/FindHIP.cmake index 1a5a8ca4b8..595ae1395a 100644 --- a/hipamd/cmake/FindHIP.cmake +++ b/hipamd/cmake/FindHIP.cmake @@ -390,6 +390,10 @@ macro(HIP_PREPARE_TARGET_COMMANDS _target _format _generated_files _source_files # Initialize list of includes with those specified by the user. Append with # ones specified to cmake directly. set(HIP_HIPCC_INCLUDE_ARGS ${HIP_HIPCC_INCLUDE_ARGS_USER}) + + # Add the include directories + list(APPEND HIP_HIPCC_INCLUDE_ARGS "-I$, -I>") + get_directory_property(_hip_include_directories INCLUDE_DIRECTORIES) list(REMOVE_DUPLICATES _hip_include_directories) if(_hip_include_directories) @@ -403,8 +407,7 @@ macro(HIP_PREPARE_TARGET_COMMANDS _target _format _generated_files _source_files HIP_PARSE_HIPCC_OPTIONS(HIP_HCC_FLAGS ${_hcc_options}) HIP_PARSE_HIPCC_OPTIONS(HIP_NVCC_FLAGS ${_nvcc_options}) - # Add the include directories && compile definitions - list(APPEND HIP_HIPCC_INCLUDE_ARGS_USER "-I$, -I>") + # Add the compile definitions list(APPEND HIP_HIPCC_FLAGS "-D$, -D>") # Check if we are building shared library. From 1e5552f8614c16a7e35124f8bc44dfd5afff87e6 Mon Sep 17 00:00:00 2001 From: Jorghi12 Date: Thu, 12 Jul 2018 14:17:21 -0400 Subject: [PATCH 3/5] Update FindHIP.cmake Adding another flag. --- hipamd/cmake/FindHIP.cmake | 1 + 1 file changed, 1 insertion(+) diff --git a/hipamd/cmake/FindHIP.cmake b/hipamd/cmake/FindHIP.cmake index 595ae1395a..7eb608a14f 100644 --- a/hipamd/cmake/FindHIP.cmake +++ b/hipamd/cmake/FindHIP.cmake @@ -28,6 +28,7 @@ mark_as_advanced(HIP_HOST_COMPILATION_CPP) ############################################################################### # Copy the invocation styles from CXX to HIP set(CMAKE_HIP_ARCHIVE_CREATE ${CMAKE_CXX_ARCHIVE_CREATE}) +set(CMAKE_HIP_ARCHIVE_APPEND ${CMAKE_CXX_ARCHIVE_APPEND}) set(CMAKE_HIP_ARCHIVE_FINISH ${CMAKE_CXX_ARCHIVE_FINISH}) set(CMAKE_SHARED_LIBRARY_SONAME_HIP_FLAG ${CMAKE_SHARED_LIBRARY_SONAME_CXX_FLAG}) set(CMAKE_SHARED_LIBRARY_CREATE_HIP_FLAGS ${CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS}) From 4abcf5dbc48cfcb104b0a3b33d07c3f59be8fa38 Mon Sep 17 00:00:00 2001 From: Jorghi12 Date: Wed, 18 Jul 2018 23:02:11 -0400 Subject: [PATCH 4/5] Update FindHIP.cmake Using Bool expression to handle empty case. --- hipamd/cmake/FindHIP.cmake | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/hipamd/cmake/FindHIP.cmake b/hipamd/cmake/FindHIP.cmake index 7eb608a14f..f5e7f0c114 100644 --- a/hipamd/cmake/FindHIP.cmake +++ b/hipamd/cmake/FindHIP.cmake @@ -36,7 +36,7 @@ set(CMAKE_SHARED_LIBRARY_HIP_FLAGS ${CMAKE_SHARED_LIBRARY_CXX_FLAGS}) set(CMAKE_SHARED_LIBRARY_LINK_HIP_FLAGS ${CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS}) set(CMAKE_SHARED_LIBRARY_RUNTIME_HIP_FLAG ${CMAKE_SHARED_LIBRARY_RUNTIME_CXX_FLAG}) set(CMAKE_SHARED_LIBRARY_RUNTIME_HIP_FLAG_SEP ${CMAKE_SHARED_LIBRARY_RUNTIME_CXX_FLAG_SEP}) -set(CMAKE_SHARED_LIBRARY_LINK_STATIC_HIP_FLAGS ${CMAKE_SHARED_LIBRARY_LINK_STATIC_CXX_FLAGS}) +set(CMAKE_SHARED_LIBRARY_LINK_STATIC_HIP_FLAGS ${CMAKE_SHARED_LIBRARY_LIN$K_STATIC_CXX_FLAGS}) set(CMAKE_SHARED_LIBRARY_LINK_DYNAMIC_HIP_FLAGS ${CMAKE_SHARED_LIBRARY_LINK_DYNAMIC_CXX_FLAGS}) # Set the CMake Flags to use the HCC Compilier. @@ -393,7 +393,8 @@ macro(HIP_PREPARE_TARGET_COMMANDS _target _format _generated_files _source_files set(HIP_HIPCC_INCLUDE_ARGS ${HIP_HIPCC_INCLUDE_ARGS_USER}) # Add the include directories - list(APPEND HIP_HIPCC_INCLUDE_ARGS "-I$, -I>") + set(include_directories_generator "$") + list(APPEND HIP_HIPCC_INCLUDE_ARGS "$<$:-I$>") get_directory_property(_hip_include_directories INCLUDE_DIRECTORIES) list(REMOVE_DUPLICATES _hip_include_directories) @@ -409,7 +410,8 @@ macro(HIP_PREPARE_TARGET_COMMANDS _target _format _generated_files _source_files HIP_PARSE_HIPCC_OPTIONS(HIP_NVCC_FLAGS ${_nvcc_options}) # Add the compile definitions - list(APPEND HIP_HIPCC_FLAGS "-D$, -D>") + set(compile_definition_generator "$") + list(APPEND HIP_HIPCC_FLAGS "$<$:-D$>") # Check if we are building shared library. set(_hip_build_shared_libs FALSE) From 4637e11a2440f494a9d849f617df331e244dc9cc Mon Sep 17 00:00:00 2001 From: Maneesh Gupta Date: Mon, 23 Jul 2018 10:39:45 +0530 Subject: [PATCH 5/5] Fix typo in FindHIP.cmake --- hipamd/cmake/FindHIP.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hipamd/cmake/FindHIP.cmake b/hipamd/cmake/FindHIP.cmake index f5e7f0c114..9a1a285921 100644 --- a/hipamd/cmake/FindHIP.cmake +++ b/hipamd/cmake/FindHIP.cmake @@ -36,7 +36,7 @@ set(CMAKE_SHARED_LIBRARY_HIP_FLAGS ${CMAKE_SHARED_LIBRARY_CXX_FLAGS}) set(CMAKE_SHARED_LIBRARY_LINK_HIP_FLAGS ${CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS}) set(CMAKE_SHARED_LIBRARY_RUNTIME_HIP_FLAG ${CMAKE_SHARED_LIBRARY_RUNTIME_CXX_FLAG}) set(CMAKE_SHARED_LIBRARY_RUNTIME_HIP_FLAG_SEP ${CMAKE_SHARED_LIBRARY_RUNTIME_CXX_FLAG_SEP}) -set(CMAKE_SHARED_LIBRARY_LINK_STATIC_HIP_FLAGS ${CMAKE_SHARED_LIBRARY_LIN$K_STATIC_CXX_FLAGS}) +set(CMAKE_SHARED_LIBRARY_LINK_STATIC_HIP_FLAGS ${CMAKE_SHARED_LIBRARY_LINK_STATIC_CXX_FLAGS}) set(CMAKE_SHARED_LIBRARY_LINK_DYNAMIC_HIP_FLAGS ${CMAKE_SHARED_LIBRARY_LINK_DYNAMIC_CXX_FLAGS}) # Set the CMake Flags to use the HCC Compilier.