@@ -33,8 +33,6 @@ project(hip)
33
33
# cmake -DBUILD_SHARED_LIBS=OFF -DCMAKE_BUILD_TYPE=Debug -DCMAKE_PREFIX_PATH="$ROCclr_DIR/build;/opt/rocm/" -DCMAKE_INSTALL_PREFIX=</where/to/install/hip> ..
34
34
# If you don't specify CMAKE_INSTALL_PREFIX, hip-rocclr runtime will be installed to "/opt/rocm/hip".
35
35
36
- set (BUILD_SHARED_LIBS ON CACHE BOOL "Build shared library (.so) or static lib (.a) " )
37
-
38
36
set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR} /cmake" )
39
37
40
38
#############################
@@ -50,6 +48,12 @@ else()
50
48
set (_pchStatus 0 )
51
49
endif ()
52
50
51
+ # With HIP project split plan, for interim puropose it is REQUIRED to pass
52
+ # HIP_AMD_BACKEND_SOURCE_DIR=<hipamd source dir> as cmake variable_
53
+ if (NOT DEFINED HIP_AMD_BACKEND_SOURCE_DIR )
54
+ message (FATAL_ERROR "HIP_AMD_BACKEND_SOURCE_DIR not defined " )
55
+ endif ()
56
+
53
57
#############################
54
58
# Setup config generation
55
59
#############################
@@ -63,6 +67,8 @@ endmacro()
63
67
#############################
64
68
# Setup version information
65
69
#############################
70
+ # hipconfig is a perl script and is not trivially invokable on Windows.
71
+ if (NOT WIN32 )
66
72
# Determine HIP_BASE_VERSION
67
73
set (ENV{HIP_PATH} "" )
68
74
execute_process (COMMAND ${CMAKE_CURRENT_SOURCE_DIR} /bin/hipconfig --version
@@ -72,11 +78,13 @@ string(REPLACE "." ";" VERSION_LIST ${HIP_BASE_VERSION})
72
78
list (GET VERSION_LIST 0 HIP_VERSION_MAJOR )
73
79
list (GET VERSION_LIST 1 HIP_VERSION_MINOR )
74
80
set (HIP_VERSION_GITDATE 0 )
81
+ endif ()
75
82
76
83
find_package (Git )
77
84
78
85
# FIXME: Two different version strings used.
79
- if (GIT_FOUND )
86
+ # Below we use UNIX commands, not compatible with Windows.
87
+ if (GIT_FOUND AND (NOT WIN32 ))
80
88
# get date information based on UTC
81
89
# use the last two digits of year + week number + day in the week as HIP_VERSION_GITDATE
82
90
# use the commit date, instead of build date
@@ -210,25 +218,6 @@ message(STATUS "HIP Compiler: " ${HIP_COMPILER})
210
218
add_to_config (_buildInfo HIP_RUNTIME )
211
219
add_to_config (_buildInfo HIP_COMPILER )
212
220
213
- ############ If HIP_PLATFORM is amd, HSA_PATH has to be defined ##################
214
-
215
- if (HIP_PLATFORM STREQUAL "amd" )
216
- # Determine HSA_PATH
217
- if (NOT DEFINED HSA_PATH )
218
- if (NOT DEFINED ENV{HSA_PATH} )
219
- set (HSA_PATH "/opt/rocm/hsa" CACHE PATH "Path to which HSA runtime has been installed" )
220
- else ()
221
- set (HSA_PATH $ENV{HSA_PATH} CACHE PATH "Path to which HSA runtime has been installed" )
222
- endif ()
223
- endif ()
224
- if (IS_ABSOLUTE ${HSA_PATH} AND EXISTS ${HSA_PATH} AND IS_DIRECTORY ${HSA_PATH} )
225
- message (STATUS "Looking for HSA runtime in: " ${HSA_PATH} )
226
- else ()
227
- message (FATAL_ERROR "Don't know where to find HSA runtime. Please specify absolute path using -DHSA_PATH" )
228
- endif ()
229
- endif ()
230
- message (STATUS "HSA runtime in: " ${HSA_PATH} )
231
-
232
221
# Set default build type
233
222
if (NOT CMAKE_BUILD_TYPE )
234
223
set (CMAKE_BUILD_TYPE "Release" )
@@ -280,6 +269,13 @@ if (BUILD_HIPIFY_CLANG)
280
269
add_subdirectory (hipify-clang )
281
270
endif ()
282
271
272
+ # Workaround for current versioning logic not being compatible with Windows
273
+ if (WIN32 )
274
+ set (HIP_VERSION_MAJOR 0 )
275
+ set (HIP_VERSION_MINOR 0 )
276
+ set (HIP_VERSION_GITDATE 0 )
277
+ endif ()
278
+
283
279
# Generate hip_version.h
284
280
set (_versionInfoHeader
285
281
"// Auto-generated by cmake\n
@@ -295,11 +291,8 @@ set(_versionInfoHeader
295
291
file (WRITE "${PROJECT_BINARY_DIR} /include/hip/hip_version.h" ${_versionInfoHeader} )
296
292
297
293
if (HIP_RUNTIME STREQUAL "rocclr" )
298
- add_subdirectory (rocclr )
299
-
300
- set (HIP_ROCclr_BUILD_FLAGS "${HIP_ROCclr_BUILD_FLAGS} -fPIC ${ROCclr_CXX_FLAGS} -I${HSA_PATH} /include" )
301
- set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${HIP_ROCclr_BUILD_FLAGS} " )
302
- set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${HIP_ROCclr_BUILD_FLAGS} " )
294
+ set (HIP_COMMON_DIR ${PROJECT_SOURCE_DIR} )
295
+ add_subdirectory (${HIP_AMD_BACKEND_SOURCE_DIR} src/hipamd )
303
296
endif ()
304
297
305
298
# Generate .hipInfo
@@ -329,16 +322,20 @@ install(FILES ${PROJECT_BINARY_DIR}/.hipVersion DESTINATION bin)
329
322
execute_process (COMMAND test ${CMAKE_INSTALL_PREFIX} -ef ${CMAKE_CURRENT_SOURCE_DIR}
330
323
RESULT_VARIABLE INSTALL_SOURCE )
331
324
if (NOT ${INSTALL_SOURCE} EQUAL 0 )
332
- if (HIP_RUNTIME STREQUAL "rocclr" )
333
- install (DIRECTORY rocclr DESTINATION . )
325
+ # Exclude .bat files on Linux.
326
+ if (WIN32 )
327
+ install (DIRECTORY bin DESTINATION . USE_SOURCE_PERMISSIONS )
328
+ else ()
329
+ install (DIRECTORY bin DESTINATION . USE_SOURCE_PERMISSIONS
330
+ PATTERN *.bat EXCLUDE )
334
331
endif ()
335
- install (DIRECTORY bin DESTINATION . USE_SOURCE_PERMISSIONS )
336
332
337
333
# The following two lines will be removed after upstream updation
338
334
install (CODE "MESSAGE(\" Removing ${CMAKE_INSTALL_PREFIX} /include\" )" )
339
335
install (CODE "file(REMOVE_RECURSE ${CMAKE_INSTALL_PREFIX} /include)" )
340
336
341
337
install (DIRECTORY include DESTINATION . )
338
+ install (DIRECTORY ${HIP_AMD_BACKEND_SOURCE_DIR} /include/hip/ DESTINATION include /hip/ )
342
339
install (DIRECTORY cmake DESTINATION . )
343
340
endif ()
344
341
@@ -354,6 +351,8 @@ install(FILES ${PROJECT_BINARY_DIR}/include/hip/hip_version.h
354
351
#############################
355
352
# hip-config
356
353
#############################
354
+ # Packaging invokes UNIX commands, which are not available on Windows.
355
+ if (NOT WIN32 )
357
356
include (CMakePackageConfigHelpers )
358
357
359
358
configure_package_config_file (
@@ -460,6 +459,7 @@ endif()
460
459
if (POLICY CMP0037 )
461
460
cmake_policy (POP )
462
461
endif ()
462
+ endif ()
463
463
464
464
#############################
465
465
# Code analysis
@@ -485,16 +485,20 @@ endif()
485
485
#############################
486
486
# Testing steps
487
487
#############################
488
+ # HIT is not compatible with Windows
489
+ if (NOT WIN32 )
488
490
set (HIP_ROOT_DIR ${CMAKE_CURRENT_BINARY_DIR} )
489
491
set (HIP_SRC_PATH ${CMAKE_CURRENT_SOURCE_DIR} )
490
492
if (HIP_PLATFORM STREQUAL "nvidia" )
491
493
execute_process (COMMAND "${CMAKE_COMMAND} " -E copy_directory "${HIP_SRC_PATH} /include" "${HIP_ROOT_DIR} /include" RESULT_VARIABLE RUN_HIT ERROR_QUIET )
492
494
endif ()
495
+ execute_process (COMMAND "${CMAKE_COMMAND} " -E copy_directory "${HIP_AMD_BACKEND_SOURCE_DIR} /include/hip/" "${HIP_ROOT_DIR} /include/hip/" RESULT_VARIABLE RUN_HIT ERROR_QUIET )
493
496
execute_process (COMMAND "${CMAKE_COMMAND} " -E copy_directory "${HIP_SRC_PATH} /cmake" "${HIP_ROOT_DIR} /cmake" RESULT_VARIABLE RUN_HIT ERROR_QUIET )
494
497
if (${RUN_HIT} EQUAL 0 )
495
498
execute_process (COMMAND "${CMAKE_COMMAND} " -E copy_directory "${HIP_SRC_PATH} /bin" "${HIP_ROOT_DIR} /bin" RESULT_VARIABLE RUN_HIT ERROR_QUIET )
496
499
endif ()
497
500
if (HIP_CATCH_TEST EQUAL "1" )
501
+ enable_testing ()
498
502
add_subdirectory (${CMAKE_CURRENT_SOURCE_DIR} /tests/catch )
499
503
else ()
500
504
if (${RUN_HIT} EQUAL 0 )
@@ -505,6 +509,7 @@ else()
505
509
message (STATUS "Testing targets will not be available. To enable them please ensure that the HIP installation directory is writeable. Use -DCMAKE_INSTALL_PREFIX to specify a suitable location" )
506
510
endif ()
507
511
endif ()
512
+ endif ()
508
513
509
514
#############################
510
515
# Code analysis
0 commit comments