操作
A/I #14
未完了Windows下でMinGWを使わず、Intel C++ Compiler(oneAPI)とCMakeを使ってPROJ等サードパーティをリンクしたプログラムが作れるか?
開始日:
2025/05/30
期日:
予定工数:
開発 次郎 さんが3ヶ月前に更新 · 編集済み
調査メモ¶
SYCL(シクル)について
- SYCL(Standard C++ for Heterogeneous Computing) は、Khronos Groupによって策定されたオープンな標準で、CPU、GPU、FPGAなどの異なるハードウェア上で並列処理を記述するためのC++ライブラリです。
- SYCLの特徴
- C++ベース:テンプレート、ラムダ式、クラスなど、C++の機能を活用可能。
- ヘテロジニアス対応:CPU、GPU、FPGAなど、複数のデバイスに対応。
- シングルソース:ホストとデバイスのコードを同じソースファイルに記述可能。
- オープンスタンダード:Khronos Groupによる標準化、複数のベンダーが実装可能。
- SYCLとoneAPIの関係
コンポーネント 役割 DPC++ (Data Parallel C++) Intelが拡張したSYCLの実装。SYCL + Intel独自の機能(USMなど) oneAPI DPC++を含むツールチェーン全体(コンパイラ、ライブラリ、デバッガなど) SYCL oneAPIの中核となるプログラミングモデル
- SYCLで書かれたコードの例(DPC++)
#include <CL/sycl.hpp> using namespace sycl; int main() { queue q; const int N = 1024; std::vector<int> data(N, 1); buffer<int> buf(data.data(), range<1>(N)); q.submit([&](handler& h) { auto acc = buf.get_access<access::mode::read_write>(h); h.parallel_for(range<1>(N), [=](id<1> i) { acc[i] *= 2; }); }); q.wait(); // data は 2 に更新される }
開発 次郎 さんが3ヶ月前に更新 · 編集済み
調査メモ¶
CMakeによるoneAPIビルド
CMAKE_C_COMPILERにicxを、CMAKE_CXX_COMPILERにicpxを指定します。
find_packageでIntelSYCLパッケージを読み込みます(古い記事だとIntelDPCPPとなっていますが、これはDeprecatedになりました)。
SYCLのカーネルが含まれるcppファイルを、add_sycl_to_targetで指定します。
target_compile_optionsとtarget_link_optionsで-fsycl-targetsを指定します。
以下サンプルです。
set(CMAKE_CXX_COMPILER icpx)
set(CMAKE_C_COMPILER icx)
cmake_minimum_required(VERSION 3.25)
project(main LANGUAGES CXX)
find_package(IntelSYCL REQUIRED)
add_executable(main main.cpp)
add_sycl_to_target(TARGET main SOURCES main.cpp)
target_compile_options(main PRIVATE
-fsycl-targets=spir64,nvptx64-nvidia-cuda)
target_link_options(main PRIVATE
-fsycl-targets=spir64,nvptx64-nvidia-cuda)
開発 次郎 さんが3ヶ月前に更新 · 編集済み
試行メモ¶
zlibをマイクロソフトCMakeでビルドしてみる。
D:\temp\cmake_zlib\zlib>"D:\Tools\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvars64.bat"
**********************************************************************
** Visual Studio 2022 Developer Command Prompt v17.14.13
** Copyright (c) 2025 Microsoft Corporation
**********************************************************************
[vcvarsall.bat] Environment initialized for: 'x64'
D:\temp\cmake_zlib>git clone https://github.com/madler/zlib
Cloning into 'zlib'...
remote: Enumerating objects: 7297, done.
remote: Counting objects: 100% (1/1), done.
remote: Total 7297 (delta 0), reused 0 (delta 0), pack-reused 7296 (from 1)
Receiving objects: 100% (7297/7297), 4.33 MiB | 2.81 MiB/s, done.
Resolving deltas: 100% (5170/5170), done.
D:\temp\cmake_zlib\zlib>cmake -G "Visual Studio 17 2022" -A x64 -T host=x64 -DCMAKE_BUILD_TYPE=Release -B build -S .
-- The C compiler identification is MSVC 19.44.35215.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: D:/Tools/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.44.35207/bin/Hostx64/x64/cl.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Looking for sys/types.h
-- Looking for sys/types.h - found
-- Looking for stdint.h
-- Looking for stdint.h - found
-- Looking for stddef.h
-- Looking for stddef.h - found
-- Check size of off64_t
-- Check size of off64_t - failed
-- Looking for fseeko
-- Looking for fseeko - not found
-- Looking for stdarg.h
-- Looking for stdarg.h - found
-- Looking for unistd.h
-- Looking for unistd.h - not found
-- Performing Test HAVE___ATTR__VIS_HIDDEN
-- Performing Test HAVE___ATTR__VIS_HIDDEN - Failed
-- Configuring done (24.2s)
-- Generating done (0.1s)
CMake Warning:
Manually-specified variables were not used by the project:
CMAKE_BUILD_TYPE
-- Build files have been written to: D:/temp/cmake_zlib/zlib/build
出典より¶
- CMakeCache.txt CMakeFiles
Generate a Project Buildsystem の時に作成されます。再作成する時に消す必要があります。
–fresh オプションをつけると再作成されます。cmake -G "Visual Studio 16 2019" -A x64 --fresh - cl : コマンド ライン error D8021: 数値型引数 '/Werror’ は無効です。
cl コンパイラーでは無効なオプションですCMakeLists.txt の行をコメントにして回避します。- https://learn.microsoft.com/ja-jp/cpp/build/reference/compiler-option-warning-level?view=msvc-170
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -Wno-covered-switch-default ")
- https://learn.microsoft.com/ja-jp/cpp/build/reference/compiler-option-warning-level?view=msvc-170
開発 次郎 さんが3ヶ月前に更新 · 編集済み
- ステータス を 新規 から 進行中 に変更
試行メモ¶
PROJ(PROJ 5.2.0。5系最後のバージョン)をWindowsのみでビルドしてみる。
PythonがいるらしいのでWindows版のPythonをインストールすることにする閉じる
D:\temp\proj-5.2.0\proj-5.2.0>cmake -G "Visual Studio 17 2022" -A x64 -T host=x64 -DCMAKE_BUILD_TYPE=Release -B build -S .
CMake Deprecation Warning at CMakeLists.txt:12 (cmake_minimum_required):
Compatibility with CMake < 3.10 will be removed from a future version of
CMake.
Update the VERSION argument <min> value. Or, use the <min>...<max> syntax
to tell CMake that the project requires at least <min> but has been updated
to work with policies introduced by <max> or earlier.
-- The C compiler identification is MSVC 19.44.35215.0
-- The CXX compiler identification is MSVC 19.44.35215.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: D:/Tools/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.44.35207/bin/Hostx64/x64/cl.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: D:/Tools/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.44.35207/bin/Hostx64/x64/cl.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
--
-- Configuring PROJ:
--
-- PROJ_VERSION = 5.2.0
-- PROJ_ABI_VERSION = 5_2
-- WARNING:
-- Could not determine compiler toolset name to set PROJ_COMPILER_NAME variable.
-- WARNING:
-- Could not determine platform name to set PROJ_COMPILER_NAME variable.
-- Looking for include file dlfcn.h
-- Looking for include file dlfcn.h - not found
-- Looking for include file inttypes.h
-- Looking for include file inttypes.h - found
-- Looking for include file jni.h
-- Looking for include file jni.h - not found
-- Looking for include file memory.h
-- Looking for include file memory.h - found
-- Looking for include file stdint.h
-- Looking for include file stdint.h - found
-- Looking for include file stdlib.h
-- Looking for include file stdlib.h - found
-- Looking for include file string.h
-- Looking for include file string.h - found
-- Looking for include file sys/stat.h
-- Looking for include file sys/stat.h - found
-- Looking for include file sys/types.h
-- Looking for include file sys/types.h - found
-- Looking for include file unistd.h
-- Looking for include file unistd.h - not found
-- Looking for 4 include files stdlib.h, ..., float.h
-- Looking for 4 include files stdlib.h, ..., float.h - found
-- Looking for localeconv
-- Looking for localeconv - found
-- Looking for ceil in m
-- Looking for ceil in m - not found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - not found
-- Found Threads: TRUE
-- Looking for PTHREAD_MUTEX_RECURSIVE
-- Looking for PTHREAD_MUTEX_RECURSIVE - not found
-- Performing Test C99_MATH
-- Performing Test C99_MATH - Success
-- PROJ_PLATFORM_NAME = win32
-- PROJ_COMPILER_NAME =
-- PROJ_TESTS = ON
--
-- Configuring proj library:
--
-- JNI_SUPPORT = OFF
-- PROJ_CORE_TARGET = proj
-- PROJ_CORE_TARGET_OUTPUT_NAME = proj_5_2
-- PROJ_LIBRARY_TYPE = STATIC
-- PROJ_LIBRARIES = proj
CMake Deprecation Warning at CMakeLists.txt:2 (cmake_minimum_required):
Compatibility with CMake < 3.10 will be removed from a future version of
CMake.
Update the VERSION argument <min> value. Or, use the <min>...<max> syntax
to tell CMake that the project requires at least <min> but has been updated
to work with policies introduced by <max> or earlier.
CMake Warning (dev) at D:/Tools/Microsoft Visual Studio/2022/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.31/Modules/ExternalProject/shared_internal_commands.cmake:1276 (message):
The DOWNLOAD_EXTRACT_TIMESTAMP option was not given and policy CMP0135 is
not set. The policy's OLD behavior will be used. When using a URL
download, the timestamps of extracted files should preferably be that of
the time of extraction, otherwise code that depends on the extracted
contents might not be rebuilt if the URL changes. The OLD behavior
preserves the timestamps from the archive instead, but this is usually not
what you want. Update your project to the NEW behavior or specify the
DOWNLOAD_EXTRACT_TIMESTAMP option with a value of true to avoid this
robustness issue.
Call Stack (most recent call first):
D:/Tools/Microsoft Visual Studio/2022/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.31/Modules/ExternalProject.cmake:3041 (_ep_add_download_command)
CMakeLists.txt:7 (ExternalProject_Add)
This warning is for project developers. Use -Wno-dev to suppress it.
-- Configuring done (0.6s)
-- Generating done (0.0s)
-- Build files have been written to: D:/temp/proj-5.2.0/proj-5.2.0/build/googletest-download
MSBuild 縺ョ繝舌・繧ク繝ァ繝ウ 17.14.19+164abd434 (.NET Framework)
1>Checking Build System
Creating directories for 'googletest'
Building Custom Rule D:/temp/proj-5.2.0/proj-5.2.0/build/googletest-download/CMakeLists.txt
Performing download step (download, verify and extract) for 'googletest'
-- Downloading...
dst='D:/temp/proj-5.2.0/proj-5.2.0/build/googletest-download/googletest-prefix/src/release-1.8.0.zip'
timeout='none'
inactivity timeout='none'
-- Using src='https://github.com/google/googletest/archive/release-1.8.0.zip'
-- verifying file...
file='D:/temp/proj-5.2.0/proj-5.2.0/build/googletest-download/googletest-prefix/src/release-1.8.0.zip'
-- Downloading... done
-- extracting...
src='D:/temp/proj-5.2.0/proj-5.2.0/build/googletest-download/googletest-prefix/src/release-1.8.0.zip'
dst='D:/temp/proj-5.2.0/proj-5.2.0/build/googletest-src'
-- extracting... [tar xfz]
-- extracting... [analysis]
-- extracting... [rename]
-- extracting... [clean up]
-- extracting... done
No update step for 'googletest'
No patch step for 'googletest'
No configure step for 'googletest'
No build step for 'googletest'
No install step for 'googletest'
No test step for 'googletest'
Completed 'googletest'
Building Custom Rule D:/temp/proj-5.2.0/proj-5.2.0/build/googletest-download/CMakeLists.txt
CMake Deprecation Warning at build/googletest-src/CMakeLists.txt:1 (cmake_minimum_required):
Compatibility with CMake < 3.10 will be removed from a future version of
CMake.
Update the VERSION argument <min> value. Or, use the <min>...<max> syntax
to tell CMake that the project requires at least <min> but has been updated
to work with policies introduced by <max> or earlier.
CMake Deprecation Warning at build/googletest-src/googlemock/CMakeLists.txt:41 (cmake_minimum_required):
Compatibility with CMake < 3.10 will be removed from a future version of
CMake.
Update the VERSION argument <min> value. Or, use the <min>...<max> syntax
to tell CMake that the project requires at least <min> but has been updated
to work with policies introduced by <max> or earlier.
CMake Deprecation Warning at build/googletest-src/googletest/CMakeLists.txt:48 (cmake_minimum_required):
Compatibility with CMake < 3.10 will be removed from a future version of
CMake.
Update the VERSION argument <min> value. Or, use the <min>...<max> syntax
to tell CMake that the project requires at least <min> but has been updated
to work with policies introduced by <max> or earlier.
CMake Warning (dev) at build/googletest-src/googletest/cmake/internal_utils.cmake:209 (find_package):
Policy CMP0148 is not set: The FindPythonInterp and FindPythonLibs modules
are removed. Run "cmake --help-policy CMP0148" for policy details. Use
the cmake_policy command to set the policy and suppress this warning.
Call Stack (most recent call first):
build/googletest-src/googletest/CMakeLists.txt:60 (include)
This warning is for project developers. Use -Wno-dev to suppress it.
-- Could NOT find PythonInterp (missing: PYTHON_EXECUTABLE)
-- Configuring done (31.3s)
-- Generating done (0.2s)
-- Build files have been written to: D:/temp/proj-5.2.0/proj-5.2.0/build
D:\temp\proj-5.2.0\proj-5.2.0>"D:\Tools\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvars64.bat"
**********************************************************************
** Visual Studio 2022 Developer Command Prompt v17.14.13
** Copyright (c) 2025 Microsoft Corporation
**********************************************************************
[vcvarsall.bat] Environment initialized for: 'x64'
D:\temp\proj-5.2.0\proj-5.2.0>cmake -G "Visual Studio 17 2022" -A x64 -T host=x64 -DCMAKE_BUILD_TYPE=Release -B build -S .
CMake Deprecation Warning at CMakeLists.txt:12 (cmake_minimum_required):
Compatibility with CMake < 3.10 will be removed from a future version of
CMake.
Update the VERSION argument <min> value. Or, use the <min>...<max> syntax
to tell CMake that the project requires at least <min> but has been updated
to work with policies introduced by <max> or earlier.
--
-- Configuring PROJ:
--
-- PROJ_VERSION = 5.2.0
-- PROJ_ABI_VERSION = 5_2
-- WARNING:
-- Could not determine compiler toolset name to set PROJ_COMPILER_NAME variable.
-- WARNING:
-- Could not determine platform name to set PROJ_COMPILER_NAME variable.
-- PROJ_PLATFORM_NAME = win32
-- PROJ_COMPILER_NAME =
-- PROJ_TESTS = ON
--
-- Configuring proj library:
--
-- JNI_SUPPORT = OFF
-- PROJ_CORE_TARGET = proj
-- PROJ_CORE_TARGET_OUTPUT_NAME = proj_5_2
-- PROJ_LIBRARY_TYPE = STATIC
-- PROJ_LIBRARIES = proj
CMake Deprecation Warning at CMakeLists.txt:2 (cmake_minimum_required):
Compatibility with CMake < 3.10 will be removed from a future version of
CMake.
Update the VERSION argument <min> value. Or, use the <min>...<max> syntax
to tell CMake that the project requires at least <min> but has been updated
to work with policies introduced by <max> or earlier.
CMake Warning (dev) at D:/Tools/Microsoft Visual Studio/2022/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.31/Modules/ExternalProject/shared_internal_commands.cmake:1276 (message):
The DOWNLOAD_EXTRACT_TIMESTAMP option was not given and policy CMP0135 is
not set. The policy's OLD behavior will be used. When using a URL
download, the timestamps of extracted files should preferably be that of
the time of extraction, otherwise code that depends on the extracted
contents might not be rebuilt if the URL changes. The OLD behavior
preserves the timestamps from the archive instead, but this is usually not
what you want. Update your project to the NEW behavior or specify the
DOWNLOAD_EXTRACT_TIMESTAMP option with a value of true to avoid this
robustness issue.
Call Stack (most recent call first):
D:/Tools/Microsoft Visual Studio/2022/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.31/Modules/ExternalProject.cmake:3041 (_ep_add_download_command)
CMakeLists.txt:7 (ExternalProject_Add)
This warning is for project developers. Use -Wno-dev to suppress it.
-- Configuring done (0.1s)
-- Generating done (0.1s)
-- Build files have been written to: D:/temp/proj-5.2.0/proj-5.2.0/build/googletest-download
MSBuild 縺ョ繝舌・繧ク繝ァ繝ウ 17.14.19+164abd434 (.NET Framework)
1>Checking Build System
Building Custom Rule D:/temp/proj-5.2.0/proj-5.2.0/build/googletest-download/CMakeLists.txt
Building Custom Rule D:/temp/proj-5.2.0/proj-5.2.0/build/googletest-download/CMakeLists.txt
CMake Deprecation Warning at build/googletest-src/CMakeLists.txt:1 (cmake_minimum_required):
Compatibility with CMake < 3.10 will be removed from a future version of
CMake.
Update the VERSION argument <min> value. Or, use the <min>...<max> syntax
to tell CMake that the project requires at least <min> but has been updated
to work with policies introduced by <max> or earlier.
CMake Deprecation Warning at build/googletest-src/googlemock/CMakeLists.txt:41 (cmake_minimum_required):
Compatibility with CMake < 3.10 will be removed from a future version of
CMake.
Update the VERSION argument <min> value. Or, use the <min>...<max> syntax
to tell CMake that the project requires at least <min> but has been updated
to work with policies introduced by <max> or earlier.
CMake Deprecation Warning at build/googletest-src/googletest/CMakeLists.txt:48 (cmake_minimum_required):
Compatibility with CMake < 3.10 will be removed from a future version of
CMake.
Update the VERSION argument <min> value. Or, use the <min>...<max> syntax
to tell CMake that the project requires at least <min> but has been updated
to work with policies introduced by <max> or earlier.
CMake Warning (dev) at build/googletest-src/googletest/cmake/internal_utils.cmake:209 (find_package):
Policy CMP0148 is not set: The FindPythonInterp and FindPythonLibs modules
are removed. Run "cmake --help-policy CMP0148" for policy details. Use
the cmake_policy command to set the policy and suppress this warning.
Call Stack (most recent call first):
build/googletest-src/googletest/CMakeLists.txt:60 (include)
This warning is for project developers. Use -Wno-dev to suppress it.
-- Found PythonInterp: D:/Tools/Python312/python.exe (found version "3.12.10")
-- Configuring done (1.2s)
-- Generating done (1.4s)
-- Build files have been written to: D:/temp/proj-5.2.0/proj-5.2.0/build
- oneAPIでビルドしてみた
D:\temp\proj-5.2.0\proj-5.2.0\build>"D:\Tools\oneAPI\setvars.bat" D:\temp\proj-5.2.0\proj-5.2.0\build>cmake -G "Visual Studio 17 2022" -A x64 -T host=x64 -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=icx -DCMAKE_CXX_COMPILER=icpx --fresh -B build -S . (省略) D:\temp\proj-5.2.0\proj-5.2.0\build>cmake -build . --config Release
動的ライブラリが生成できていない
操作