CMake projects in Windows 11

Home and Applets > Download SVD-GPU Application Source Code > CMake Projects in Windows 11

Install CMake 3.31. See installing CMake, its documentation, and successfully use CMake. Out-of-source build is chosen for the following projects.

CMake 3.31 CMakeLists.txt for deviceQuery.cpp

  1. First, generate deviceQuery folder on Windows 11 desktop.
    Then add src folder and an empty CMakeLists.txt file in deviceQuery folder.

  2. Copy and paste the file C:\Users\pm\source\repos\cuda-samples-12.5\Samples\1_Utilities\deviceQuery\deviceQuery.cpp into src folder, which contains one file.
  3. Paste the following CMake 3.30 file into CMakeLists.txt
    # CMakeLists.txt to build deviceQuery.cpp
    cmake_minimum_required(VERSION 3.30)
    message(STATUS "CMake version: ${CMAKE_VERSION}")
    
    project(deviceQuery VERSION 1.0
            DESCRIPTION "My first C++ program"
            LANGUAGES CXX)
    
    find_package(CUDAToolkit)
    
    # For compilation ...
    # Specify binary name & source file to build it from
    add_executable(
        ${PROJECT_NAME}
        src/deviceQuery.cpp
    )
    
    # Specify target & include directories
    target_include_directories(
        ${PROJECT_NAME}
        PRIVATE
        "C:/Users/pm/source/repos/cuda-samples-12.5/Common"
    )
    
    # For linking ...
    # Specify target & libraries to link it with
    target_link_libraries(
        ${PROJECT_NAME}
        PRIVATE
        CUDA::cudart
    )

deviceQuery.cpp project with Eclipse CDT4 - MinGW Makefiles generator

  1. Generate build-deviceQuery-Eclipse folder on Windows 11 desktop.

  2. Launch CMake 3.31 GUI.
  3. Click File menu then select Delete Cache.
    Provide the path of deviceQuery folder in Where is the source code.
    Provide the path of build-deviceQuery-Eclipse folder in Where to build the binaries.

    Click Configure button.
  4. Select Eclipse CDT4 - MinGW Makefiles for Specify the generator for this project.

    Click Finish button.
  5. Click Configure button.

  6. Click Generate button.
  7. Fives files and two folders are generated in build-deviceQuery-Eclipse folder.

  8. Launch Eclipse for Java developers.
  9. Click File menu then select Import...
    Import panel appears.
    Select Existing Projects into Workspace.

    Click Next > button.
  10. Import Projects panel appears.

    Click Browse... button.
  11. Select Folder dialog appears.
    Select build-deviceQuery-Eclipse folder.
    Click Select folder button.
  12. Import Projects panel appears.

    Click Finish button.
  13. Project Explorer of Eclipse is filled.

    Click all button of Build Targets.
  14. Compilation data appear on Console tab.
    The 64-bit executable file, deviceQuery.exe - [amd64/le], appears in Binaries folder of Project Explorer.
    It is available in build-deviceQuery-Eclipse folder.

  15. Right-click deviceQuery.exe - [amd64/le] in Project Explorer.
    Select Run As then Local C/C++ Application.

deviceQuery.cpp project with Eclipse plugin cmake4eclipse

  1. We re-use the deviceQuery folder generated previously on Windows 11 desktop.
  2. cmake4eclipse is a plugin that is available via the marketplace.
    Click Help menu in Eclipse IDE and select Eclipse Marketplace...
  3. Eclipse Marketplace window appears. Enter cmake4eclipe in Find box.

    Press Install button.
  4. Create a new C++ project in the location of our current project (the folder containing the CMakeLists.txt file and the src folder).
    Press CTRL N to open Select a wizard panel.
    Select C/C++ Project. Click Next > Button.
    New C/C++ Project panel appears.
    Select Cmake4eclipse Managed Build.

    Click Next > button.
  5. C/C++ Project panel appears.
    Provide Project name: build-cmake-deviceQuery
    Uncheck Use default location.
    Click Browse... button then provide the location
    C:\Users\pm\OneDrive\Bureau\deviceQuery

    Click Finish button.
  6. The project appears in Project Explorer.

  7. Click all button in the project folder.

  8. Right-click deviceQuery.exe - [amd64/le], then select Run As, finally select Local C/C++ Application.

deviceQuery.cpp project with Visual Studio 17 2022 generator

  1. Generate deviceQuery folder on Windows 11 desktop as in Section 1.
  2. Generate an empty build-deviceQuery-VS2015 folder on Windows 11 desktop.
  3. Launch CMake 3.31 GUI.
  4. Click File menu then select Delete Cache.
    Provide the path of deviceQuery folder in Where is the source code.
    Provide the path of build-deviceQuery-VS2022 folder in Where is build binaries.

    Click Configure button.
  5. Select Visual Studio 14 2015 for Specify the generator for the project.
    Select x64 for Optional platform for generator (if empty, generator user: Win32)

    Click Finish button.

  6. Click Generate button.
  7. Nine files and one folder are generated in build-deviceQuery-VS2022 folder.

  8. Open build-deviceQuery-VS2022 folder.
    Right-click deviceQuery.sln.
    Select Open with... then Microsoft Visual Studio 2022.
  9. VS2022 is in Debug configuration and x64 environment.

  10. Select Build menu then Build Solution.

  11. The 64-bit executable file, deviceQuery.exe, is available in Debug folder of build-deviceQuery-VS2022 folder.

CMake 3.31 CMakeLists.txt for svdComplexDevice1.dll

  1. Generate svdComplexDevice1 folder on desktop of Windows 11.
    Add src folder and empty CMakeLists.txt file in svdComplexDevice1 folder.
  2. src folder contains two files: svdComplexDevice1.cpp file and svdComplexDevice1.h file.
  3. Paste the following CMake 3.31 file into CMakeLists.txt
    # CMakeLists.txt to build svdComplexDevice1.cpp
    cmake_minimum_required(VERSION 3.30)
    message(STATUS "CMake version: ${CMAKE_VERSION}")
    
    project(svdComplexDevice1 VERSION 1.0
            DESCRIPTION "My first DLL program"
            LANGUAGES CXX)
    
    find_package(CUDAToolkit)
    
    if(${CUDAToolkit_FOUND})
        message(STATUS "Found lib CXX: ${CMAKE_CXX_STANDARD_LIBRARIES}")
        message(STATUS "Found CXX compiler: ${CMAKE_CXX_COMPILER}")
    endif(${CUDAToolkit_FOUND})
    
    # For compilation ...
    # Specify binary name & source files to build it from
    add_library(
        ${PROJECT_NAME}
        SHARED
        src/svdComplexDevice1.h
        src/svdComplexDevice1.cpp
    )
    
    # Specify target & CULA include directories
    target_include_directories(
        ${PROJECT_NAME}
        PRIVATE
        "C:/Program Files/CULA/R15/include"
    )
    
    # Specify target & CULA library paths
    target_link_directories(
        ${PROJECT_NAME}
        PRIVATE
        "C:/Program Files/CULA/R15/lib64"
    )
    
    # For linking ...
    # Specify target & libraries to link it with
    target_link_libraries(
        ${PROJECT_NAME}
        PUBLIC
        CUDA::cudart
        CUDA::cublas
        cula_core
        cula_lapack
    )

svdComplexDevice1.dll project with Eclipse plugin cmake4eclipse

  1. Launch Eclipse for Java developers.
  2. Follow the procedure described for deviceQuery.cpp project in Section 3
    ....................

  3. The 64-bit dll file with 112 Kb size, libsvdComplexDevice1.dll - [amd64/le], appears in Binaries folder of Project Explorer.
    It is available in svdComplexDevice1/_build/Debug folder on desktop of Windows 11.

  4. Rename libsvdComplexDevice1.dll to svdComplexDevice1.dll.

svdComplexDevice1.dll project with Visual Studio 17 2022 generator

  1. Generate build-svdComplexDevice1-VS2022 folder on desktop of Windows 11.
  2. Launch CMake 3.31 GUI.
  3. Click File menu then select Delete Cache.
    Provide the path of svdComplexDevice1 folder in Where is the source code.
    Provide the path of build-svdComplexDevice1-VS2022 folder in Where is build binaries.
    Click Configure button.
  4. Select Visual Studio 17 2022 for Specify the generator for the project.
    Select x64 for Optional platform for generator (if empty, generator user: Win32).
    Click Finish button.
  5. Follow the procedure described for deviceQuery project in Section 4
    ....................
  6. Open build-deviceQuery-VS2022 folder.
    Right-click deviceQuery.sln.
    Select Open with... then Microsoft Visual Studio 2022.
  7. Select Build menu then Build Solution.
  8. Build solution data appear on Output panel.
    The 64-bit file with 62 Kb size, svdComplexDevice1.dll, is available in Debug folder of build-svdComplexDevice1-VS2022 folder on the desktop of Windows 11.

CMake 3.31 CMakeLists.txt for bandwidthTest.cu

  1. Generate bandwidthTest folder on desktop of Windows 11.
    Add src folder and empty CMakeLists.txt file in bandwidthTest folder.
  2. Copy and paste the file C:\Users\pm\source\repos\cuda-samples-12.5\Samples\1_Utilities\bandwidthTest\bandwidthTest.cu into bandwidthTest.cu file of src folder, which contains one file.
  3. Paste the following CMake 3.31 file into CMakeLists.txt
    # CMakeLists.txt to build bandwidthTest.cu
    cmake_minimum_required(VERSION 3.30)
    
    project(bandwidthTest VERSION 1.0
            DESCRIPTION "My first CUDA program"
            LANGUAGES CUDA)
    
    message(STATUS "Found headers CUDA: ${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES}")
    message(STATUS "Found lib CUDA: ${CMAKE_CUDA_STANDARD_LIBRARIES}")
    message(STATUS "Found CUDA nvcc: ${CMAKE_CUDA_COMPILER}")
    
    # For compilation ...
    # Specify binary name & source file to build it from
    add_executable(
        ${PROJECT_NAME}
        src/bandwidthTest.cu
    )
    
    # Specify target & include directories
    target_include_directories(
        ${PROJECT_NAME}
        PRIVATE
        "C:/Users/pm/source/repos/cuda-samples-12.5/Common"
    )

bandwidthTest.cu project with Visual Studio 17 2022 generator

  1. Generate build-bandwidthTest-VS2022 folder on desktop of Windows 11.
  2. Launch CMake 3.31 GUI.
  3. Click File menu then select Delete Cache.
    Provide the path of bandwidthTest folder in Where is the source code.
    Provide the path of build-bandwidthTest-VS2022 folder in Where is build binaries.
    Click Configure button.
  4. Select Visual Studio 17 2022 for Specify the generator for the project.
    Select x64 for Optional platform for generator (if empty, generator user: Win32).
    Click Finish button.
  5. Follow the procedure described for deviceQuery project in Section 4
    ....................
  6. Select Build menu then Build Solution.
  7. Build solution data appear on Output panel.
    The 64-bit file, bandwidthTest.exe, is available in Debug folder of build-bandwidthTest-VS2022 folder on Windows 11 desktop.

CMake 3.31 CMakeLists.txt for Mandelbrot project

  1. Generate Mandelbrot folder on desktop of Windows 11.
    Add src folder and empty CMakeLists.txt file in Mandelbrot folder.
  2. Copy the six files Mandelbrot_kernel.h, Mandelbrot.cpp Mandelbrot_kernel.cuh, Mandelbrot_cuda.cu, Mandelbrot_gold.h, and Mandelbrot_gold.cpp of the folder C:\Users\pm\source\repos\cuda-samples-12.5\Samples\5_Domain_Specific\Mandelbrot into src folder.
  3. Paste the following CMake 3.31 file into CMakeLists.txt
    # CMakeLists.txt to build Mandelbrot
    cmake_minimum_required(VERSION 3.30)
    
    project(Mandelbrot VERSION 1.1
            DESCRIPTION "My first complex CUDA program"
            LANGUAGES CUDA CXX)
    
    find_package(CUDAToolkit)
    
    message(STATUS "Found headers CUDA: ${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES}")
    message(STATUS "Found lib CUDA: ${CMAKE_CUDA_STANDARD_LIBRARIES}")
    message(STATUS "Found CUDA nvcc: ${CMAKE_CUDA_COMPILER}")
    
    # For compilation ...
    # Specify binary name & source files to build it from
    add_executable(
        ${PROJECT_NAME}
        src/Mandelbrot_kernel.h
        src/Mandelbrot.cpp
        src/Mandelbrot_kernel.cuh
        src/Mandelbrot_cuda.cu
        src/Mandelbrot_gold.h
        src/Mandelbrot_gold.cpp
    )
    
    # Specify target & include directories
    target_include_directories(
        ${PROJECT_NAME}
        PRIVATE
        "C:/Users/pm/source/repos/cuda-samples-12.5/Common"
    )
    
    # Specify target & external glew64.lib library paths
    target_link_directories(
        ${PROJECT_NAME}
        PRIVATE
        "C:/Users/pm/source/repos/cuda-samples-12.5/Common/lib/x64"
    )
    
    # For linking ...
    # Specify target & libraries to link it with
    target_link_libraries(
        ${PROJECT_NAME}
        PUBLIC
        glew64
    )

Mandelbrot project with Visual Studio 17 2022 generator

  1. Generate build-Mandelbrot-VS2022 folder on desktop of Windows 11.
  2. Launch CMake 3.31 GUI.
  3. Click File menu then select Delete Cache.
    Input the path of Mandelbrot folder in Where is the source code.
    Input the path of build-Mandelbrot-VS2022 folder in Where is build binaries.
    Click Configure button.
  4. Select Visual Studio 17 2022 for Specify the generator for the project.
    Select x64 for Optional platform for generator (if empty, generator user: Win32).
    Click Finish button.
  5. Follow the procedure described for deviceQuery project in Section 3
    ....................
  6. Select Build menu then Build Solution.
  7. Build solution data appear on Output panel.
    The 64-bit file, Mandelbrot.exe, is available in Debug folder of build-Mandelbrot-VS2022 folder.
  8. Copy and paste the two files glew64.dll and freeglut.dll from the folder C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.5\extras\demo_suite into Debug folder of build-Mandelbrot-VS2022 folder.

  9. Double click Mandelbrot.exe will launch the program.

References

  1. Alexandre Laurent: Utiliser CMake pour compiler un projet
  2. Florian Goujeon: Initiation à CMake
  3. Loïc Gouarin: Introduction à CMake
  4. CMake: CMake tutoriel
  5. GitBook: An introduction to modern CMake; A simple example
  6. Deniz Bahadir: More modern CMake - Working with CMake 3.12 and later
  7. YouTube: CppCon 2017: Mathieu Ropert “Using Modern CMake patterns to enforce a good modular design”
  8. GitHub: Effective modern CMake
  9. Daniel Pfeifer: CMake - introduction and best practices
  10. Kuba Sejdak: Modern CMake is like inheritance
  11. Nick Winder: Modern CMake tips
  12. Pablo Arias: It's time to do CMake right
  13. Guru99, Barbara Thompson: C tutorial for beginners: Learn C programming language basics
  14. LLVM: CMake primer
  15. John Lamp: CMake tutorial
  16. Derek Molloy: Introduction to CMake by example
  17. Mirko Kiefer: CMake by example
  18. Dmerej's blog: Let's build Chuck Norris! - Part 1: CMake and Ninja
  19. Android Studio: Configure CMake
  20. Visual Servoing Platform Tutorial: How to create and build a project that uses ViSP and CMake on Unix or Windows
  21. Selective Intellect: How to use CMake to add third party libraries to your project
  22. Microsoft: Projets CMake dans Visual Studio
  23. Kitware Robot: Generator specific information
  24. Preshing on Programming: How to build a CMake-based project
  25. Javier V. Gómez: How to configure a C/C++ project with Eclipse and CMake
  26. StackOverflow: How to configure Eclipse CDT for Cmake?
    In Eclipse-CDT you do not create Cmake project but you import Cmake project.
  27. Packt Publishing Limited: Importing a CMake project into Eclipse CDT
  28. johnnado: Build with CMake in Eclipse
  29. gitlab.kitware: How to find libraries
  30. Simplify C++!: Hello CMake!
  31. ROS: catkin/CMakeLists.txt
    What does find_package() do?
  32. deal.II: How to use CMake to configure your projects with deal.II
  33. GitHub: How to set include directories in CMake
  34. StackOverflow: How do I add a library path in cmake?
  35. StackOverflow: Importing a CMake project into Eclipse CDT
  36. Eclipse marketspace: cmake4eclipse
  37. Debian: cmake-variables - CMake Variables Reference
  38. Archlinux: cmake-generators - CMake Generators Reference
  39. PROJ: Using PROJ in CMake projects
    By adding the imported library target to the target link libraries, CMake will also pass the include directories to the compiler. This requires that you use CMake version 2.8.11 or later.

References CUDA

  1. Code Yarns: How to build CUDA programs using CMake
  2. Nvidia developer blog: Building cross-platform CUDA applications with CMake
  3. CMake: FindCUDAToolkit
  4. Attila Krasznahorkay: Building CUDA code
  5. Stackoverflow: Obtaining the CUDA include dir in C++ targets with native-CUDA-support CMake?
    find_package(CUDAToolkit)
    add_executable(
      binary_linking_to_cudart
      my_cpp_file_using_cudart.cpp
    )
    target_link_libraries(
      binary_linking_to_cudart 
      PRIVATE 
      CUDA::cudart
    )
  6. Jared Casper: Provide target libraries for cuda libraries
  7. Siyuan Liu: CUDA as a language in CMake
  8. Luke Yeager: Example of how to use CUDA with CMake >= 3.8
  9. Jonathan R. Madsen: Build systems - GPU offloading
  10. developpez: Cmake pour CUDA project
  11. Benjamin Charlier: Find CUDA and GPUs
  12. Narkive: How do you allow CMAKE_CUDA_COMPILER to be optional via project LANGUAGE?
  13. Pierre Aubert: Le fichier CMakeLists.txt
  14. CLion: CUDA projects
  15. StackOverflow: How to compile C++ as CUDA using CMake
  16. StackOverflow: Linking of CUDA library in CMake

Solid-state NMR bibliography for:

Aluminum-27
Antimony-121/123
Arsenic-75
Barium-135/137
Beryllium-9
Bismuth-209
Boron-11
Bromine-79/81
Calcium-43
Cesium-133
Chlorine-35/37
Chromium-53
Cobalt-59
Copper-63/65
Deuterium-2
Gallium-69/71
Germanium-73
Gold-197
Hafnium-177/179
Indium-113/115
Iodine-127
Iridium-191/193
Krypton-83
Lanthanum-139
Lithium-7
Magnesium-25
Manganese-55
Mercury-201
Molybdenum-95/97
Neon-21
Nickel-61
Niobium-93
Nitrogen-14
Osmium-189
Oxygen-17
Palladium-105
Potassium-39/41
Rhenium-185/187
Rubidium-85/87
Ruthenium-99/101
Scandium-45
Sodium-23
Strontium-87
Sulfur-33
Tantalum-181
Titanium-47/49
Vanadium-51
Xenon-131
Zinc-67
Zirconium-91
[Contact me] - Last updated November 19, 2024
Copyright © 2002-2024 pascal-man.com. All rights reserved.