depot/third_party/nixpkgs/pkgs/development/libraries/rocm-comgr/cmake.patch

225 lines
7.8 KiB
Diff
Raw Normal View History

diff --git a/CMakeLists.txt b/CMakeLists.txt
index eac270a..27610ec 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -53,10 +53,6 @@ set(SOURCES
if(COMGR_BUILD_SHARED_LIBS)
add_library(amd_comgr SHARED ${SOURCES})
- # Windows doesn't have a strip utility, so CMAKE_STRIP won't be set.
- if((CMAKE_BUILD_TYPE STREQUAL "Release") AND NOT ("${CMAKE_STRIP}" STREQUAL ""))
- add_custom_command(TARGET amd_comgr POST_BUILD COMMAND ${CMAKE_STRIP} $<TARGET_FILE:amd_comgr>)
- endif()
else()
add_library(amd_comgr STATIC ${SOURCES})
endif()
@@ -141,8 +137,8 @@ if (UNIX)
list(APPEND AMD_COMGR_PUBLIC_LINKER_OPTIONS -pthread)
if (NOT APPLE AND COMGR_BUILD_SHARED_LIBS)
configure_file(
- ${CMAKE_CURRENT_SOURCE_DIR}/src/exportmap.in
- ${CMAKE_CURRENT_BINARY_DIR}/src/exportmap @ONLY)
+ src/exportmap.in
+ src/exportmap @ONLY)
list(APPEND AMD_COMGR_PRIVATE_LINKER_OPTIONS
"-Wl,--version-script=${CMAKE_CURRENT_BINARY_DIR}/src/exportmap")
# When building a shared library with -fsanitize=address we can't be
@@ -154,6 +150,9 @@ if (UNIX)
-Wl,--no-undefined)
endif()
endif()
+
+ # Strip in release build
+ set_target_properties(amd_comgr PROPERTIES LINK_FLAGS_RELEASE -s)
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
list(APPEND AMD_COMGR_PRIVATE_COMPILE_OPTIONS
"/wd4244" #[[Suppress 'argument' : conversion from 'type1' to 'type2', possible loss of data]]
@@ -169,10 +168,6 @@ endif()
# the shared header.
list(APPEND AMD_COMGR_PRIVATE_COMPILE_DEFINITIONS AMD_COMGR_EXPORT)
-configure_file(
- ${CMAKE_CURRENT_SOURCE_DIR}/include/amd_comgr.h.in
- ${CMAKE_CURRENT_BINARY_DIR}/include/amd_comgr.h @ONLY)
-
include(bc2h)
include(opencl_pch)
include(DeviceLibs)
@@ -203,8 +198,11 @@ target_compile_definitions(amd_comgr
PRIVATE "${AMD_COMGR_PRIVATE_COMPILE_DEFINITIONS}")
target_include_directories(amd_comgr
PUBLIC
- $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include>
- $<INSTALL_INTERFACE:include>)
+ $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include>)
+
+configure_file(
+ include/amd_comgr.h.in
+ include/amd_comgr.h @ONLY)
set(AMD_COMGR_CONFIG_NAME amd_comgr-config.cmake)
set(AMD_COMGR_TARGETS_NAME amd_comgr-targets.cmake)
@@ -220,29 +218,30 @@ if (NOT COMGR_BUILD_SHARED_LIBS)
endif()
set(AMD_COMGR_TARGETS_PATH
- "${CMAKE_CURRENT_BINARY_DIR}/${AMD_COMGR_PACKAGE_PREFIX}/${AMD_COMGR_TARGETS_NAME}")
-set(AMD_COMGR_VERSION_PATH
- "${CMAKE_CURRENT_BINARY_DIR}/${AMD_COMGR_PACKAGE_PREFIX}/${AMD_COMGR_VERSION_NAME}")
-export(TARGETS amd_comgr
- FILE "${AMD_COMGR_PACKAGE_PREFIX}/${AMD_COMGR_TARGETS_NAME}")
+ "${AMD_COMGR_PACKAGE_PREFIX}/${AMD_COMGR_TARGETS_NAME}")
configure_file("cmake/${AMD_COMGR_CONFIG_NAME}.in"
- "${AMD_COMGR_PACKAGE_PREFIX}/${AMD_COMGR_CONFIG_NAME}"
+ ${AMD_COMGR_CONFIG_NAME}
@ONLY)
-write_basic_package_version_file("${AMD_COMGR_VERSION_PATH}"
+write_basic_package_version_file("${CMAKE_CURRENT_BINARY_DIR}/${AMD_COMGR_VERSION_NAME}"
VERSION "${amd_comgr_VERSION}"
COMPATIBILITY SameMajorVersion)
install(TARGETS amd_comgr
EXPORT amd_comgr_export
- COMPONENT amd-comgr
- RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
- LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
- ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
+ COMPONENT amd-comgr)
+install(EXPORT amd_comgr_export
+ DESTINATION "${AMD_COMGR_PACKAGE_PREFIX}"
+ FILE "${AMD_COMGR_TARGETS_NAME}")
install(FILES
"${CMAKE_CURRENT_BINARY_DIR}/include/amd_comgr.h"
COMPONENT amd-comgr
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
+install(FILES
+ "${CMAKE_CURRENT_BINARY_DIR}/${AMD_COMGR_CONFIG_NAME}"
+ "${CMAKE_CURRENT_BINARY_DIR}/${AMD_COMGR_VERSION_NAME}"
+ COMPONENT amd-comgr
+ DESTINATION ${AMD_COMGR_PACKAGE_PREFIX})
install(FILES
"README.md"
@@ -251,37 +250,6 @@ install(FILES
COMPONENT amd-comgr
DESTINATION ${CMAKE_INSTALL_DATADIR}/amd_comgr)
-# Generate the install-tree package.
-set(AMD_COMGR_PREFIX_CODE "
-# Derive absolute install prefix from config file path.
-get_filename_component(AMD_COMGR_PREFIX \"\${CMAKE_CURRENT_LIST_FILE}\" PATH)")
-string(REGEX REPLACE "/" ";" count "${AMD_COMGR_PACKAGE_PREFIX}")
-foreach(p ${count})
- set(AMD_COMGR_PREFIX_CODE "${AMD_COMGR_PREFIX_CODE}
-get_filename_component(AMD_COMGR_PREFIX \"\${AMD_COMGR_PREFIX}\" PATH)")
-endforeach()
-
-if (NOT COMGR_BUILD_SHARED_LIBS)
- string(APPEND AMD_COMGR_PREFIX_CODE "\ninclude(CMakeFindDependencyMacro)\n")
- string(APPEND AMD_COMGR_PREFIX_CODE "find_dependency(Clang REQUIRED)\n")
- string(APPEND AMD_COMGR_PREFIX_CODE "find_dependency(LLD REQUIRED)\n")
-endif()
-
-set(AMD_COMGR_TARGETS_PATH "\${AMD_COMGR_PREFIX}/${AMD_COMGR_PACKAGE_PREFIX}/${AMD_COMGR_TARGETS_NAME}")
-configure_file("cmake/${AMD_COMGR_CONFIG_NAME}.in"
- "${CMAKE_CURRENT_BINARY_DIR}/${AMD_COMGR_CONFIG_NAME}.install"
- @ONLY)
-install(FILES
- "${CMAKE_CURRENT_BINARY_DIR}/${AMD_COMGR_CONFIG_NAME}.install"
- DESTINATION "${AMD_COMGR_PACKAGE_PREFIX}"
- RENAME "${AMD_COMGR_CONFIG_NAME}")
-install(EXPORT amd_comgr_export
- DESTINATION "${AMD_COMGR_PACKAGE_PREFIX}"
- FILE "${AMD_COMGR_TARGETS_NAME}")
-install(FILES
- "${AMD_COMGR_VERSION_PATH}"
- DESTINATION "${AMD_COMGR_PACKAGE_PREFIX}")
-
set(CLANG_LIBS
clangFrontendTool)
diff --git a/cmake/bc2h.cmake b/cmake/bc2h.cmake
index 146fe2b..9134985 100644
--- a/cmake/bc2h.cmake
+++ b/cmake/bc2h.cmake
@@ -1,40 +1,41 @@
-file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/bc2h.c
-"#include <stdio.h>\n"
-"int main(int argc, char **argv){\n"
-" FILE *ifp, *ofp;\n"
-" int c, i, l;\n"
-" if (argc != 4) return 1;\n"
-" ifp = fopen(argv[1], \"rb\");\n"
-" if (!ifp) return 1;\n"
-" i = fseek(ifp, 0, SEEK_END);\n"
-" if (i < 0) return 1;\n"
-" l = ftell(ifp);\n"
-" if (l < 0) return 1;\n"
-" i = fseek(ifp, 0, SEEK_SET);\n"
-" if (i < 0) return 1;\n"
-" ofp = fopen(argv[2], \"wb+\");\n"
-" if (!ofp) return 1;\n"
-" fprintf(ofp, \"#define %s_size %d\\n\\n\"\n"
-" \"#if defined __GNUC__\\n\"\n"
-" \"__attribute__((aligned (4096)))\\n\"\n"
-" \"#elif defined _MSC_VER\\n\"\n"
-" \"__declspec(align(4096))\\n\"\n"
-" \"#endif\\n\"\n"
-" \"static const unsigned char %s[%s_size+1] = {\",\n"
-" argv[3], l,\n"
-" argv[3], argv[3]);\n"
-" i = 0;\n"
-" while ((c = getc(ifp)) != EOF) {\n"
-" if (0 == (i&7)) fprintf(ofp, \"\\n \");\n"
-" fprintf(ofp, \" 0x%02x,\", c);\n"
-" ++i;\n"
-" }\n"
-" fprintf(ofp, \" 0x00\\n};\\n\\n\");\n"
-" fclose(ifp);\n"
-" fclose(ofp);\n"
-" return 0;\n"
-"}\n"
-)
+file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/bc2h.c
+ CONTENT
+"#include <stdio.h>
+int main(int argc, char **argv){
+ FILE *ifp, *ofp;
+ int c, i, l;
+ if (argc != 4) return 1;
+ ifp = fopen(argv[1], \"rb\");
+ if (!ifp) return 1;
+ i = fseek(ifp, 0, SEEK_END);
+ if (i < 0) return 1;
+ l = ftell(ifp);
+ if (l < 0) return 1;
+ i = fseek(ifp, 0, SEEK_SET);
+ if (i < 0) return 1;
+ ofp = fopen(argv[2], \"wb+\");
+ if (!ofp) return 1;
+ fprintf(ofp, \"#define %s_size %d\\n\\n\"
+ \"#if defined __GNUC__\\n\"
+ \"__attribute__((aligned (4096)))\\n\"
+ \"#elif defined _MSC_VER\\n\"
+ \"__declspec(align(4096))\\n\"
+ \"#endif\\n\"
+ \"static const unsigned char %s[%s_size+1] = {\",
+ argv[3], l,
+ argv[3], argv[3]);
+ i = 0;
+ while ((c = getc(ifp)) != EOF) {
+ if (0 == (i&7)) fprintf(ofp, \"\\n \");
+ fprintf(ofp, \" 0x%02x,\", c);
+ ++i;
+ }
+ fprintf(ofp, \" 0x00\\n};\\n\\n\");
+ fclose(ifp);
+ fclose(ofp);
+ return 0;
+}
+")
add_executable(bc2h ${CMAKE_CURRENT_BINARY_DIR}/bc2h.c)
if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")