CMake projects in Windows 10

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

Install CMake 3.17. Add CMake to system PATH. See Installing CMake, its documentation, and running CMake for Windows to build a project. Out-of-source build is chosen for the following projects.

CMake 3.17 CMakeLists.txt for deviceQuery.cpp

  1. Generate deviceQuery folder on Windows 10 desktop.
    Add src folder and empty CMakeLists.txt file in deviceQuery folder.

  2. Copy and paste the file C:\ProgramData\NVIDIA Corporation\CUDA Samples\v8.0\1_Utilities\deviceQuery\deviceQuery.cpp into deviceQuery.cpp file of src folder, which contains one file.
  3. Paste the following CMake 3.17 file into CMakeLists.txt
    # CMakeLists.txt to build deviceQuery.cpp
    cmake_minimum_required(VERSION 3.17)
    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:/ProgramData/NVIDIA Corporation/CUDA Samples/v8.0/common/inc"
    )
    
    # 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 10 desktop.
  2. Launch CMake 3.17 GUI.
  3. Click File menu then select Delete Cache.
    Input the path of deviceQuery folder in Where is the source code.
    Input the path of build-deviceQuery-Eclipse folder in Where is build binaries.

    Click Configure button.
  4. Select Eclipse CDT4 - MinGW Makefiles for Specify the generator for the 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 CDT.
  9. Click File menu then select Import...
    Select 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 2. Local C/C++ Application.

deviceQuery.cpp project with Visual Studio 14 2015 generator

  1. Generate build-deviceQuery-VS2015 folder on desktop of Windows 10.
  2. Launch CMake 3.17 GUI.
  3. Click File menu then select Delete Cache.
    Input the path of deviceQuery folder in Where is the source code.
    Input the path of build-deviceQuery-VS2015 folder in Where is build binaries.

    Click Configure button.
  4. 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.
  5. Click Configure button.

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

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

  10. Select Build menu then Build Solution.
  11. Build solution data appear on Output panel.
    The 64-bit executable file, deviceQuery.exe, is available in Debug folder of build-deviceQuery-VS2015 folder.

CMake 3.17 CMakeLists.txt for svdComplexDevice1.dll

  1. Generate svdComplexDevice1 folder on desktop of Windows 10.
    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.17 file into CMakeLists.txt
    # CMakeLists.txt to build svdComplexDevice1.cpp
    cmake_minimum_required(VERSION 3.17)
    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 CDT4 - MinGW Makefiles generator

  1. Generate build-svdComplexDevice1-Eclipse folder on Windows 10 desktop.
  2. Launch CMake 3.17 GUI.
  3. Click File menu then select Delete Cache.
    Input the path of svdComplexDevice1 folder in Where is the source code.
    Input the path of build-svdComplexDevice1-Eclipse folder in Where is build binaries. Click Configure button.
  4. Select Eclipse CDT4 - MinGW Makefiles for Specify the generator for the project. Click Finish button.
  5. Follow the procedure described for deviceQuery project in Section 2
    ....................
  6. Project Explorer of Eclipse CDT is filled.

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

  8. Rename libsvdComplexDevice1.dll to svdComplexDevice1.dll.

svdComplexDevice1.dll project with Visual Studio 14 2015 generator

  1. Generate build-svdComplexDevice1-VS2015 folder on desktop of Windows 10.
  2. Launch CMake 3.17 GUI.
  3. Click File menu then select Delete Cache.
    Input the path of svdComplexDevice1 folder in Where is the source code.
    Input the path of build-svdComplexDevice1-VS2015 folder in Where is build binaries.
    Click Configure button.
  4. 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.
  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, svdComplexDevice1.dll, is available in Debug folder of build-svdComplexDevice1-VS2015 folder.

CMake 3.17 CMakeLists.txt for bandwidthTest.cu

  1. Generate bandwidthTest folder on desktop of Windows 10.
    Add src folder and empty CMakeLists.txt file in bandwidthTest folder.
  2. Copy and paste the file C:\ProgramData\NVIDIA Corporation\CUDA Samples\v8.0\1_Utilities\bandwidthTest\bandwidthTest.cu into bandwidthTest.cu file of src folder, which contains one file.
  3. Paste the following CMake 3.17 file into CMakeLists.txt
    # CMakeLists.txt to build bandwidthTest.cu
    cmake_minimum_required(VERSION 3.17)
    
    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:/ProgramData/NVIDIA Corporation/CUDA Samples/v8.0/common/inc"
    )

bandwidthTest.cu project with Visual Studio 14 2015 generator

  1. Generate build-bandwidthTest-VS2015 folder on desktop of Windows 10.
  2. Launch CMake 3.17 GUI.
  3. Click File menu then select Delete Cache.
    Input the path of bandwidthTest folder in Where is the source code.
    Input the path of build-bandwidthTest-VS2015 folder in Where is build binaries.
    Click Configure button.
  4. 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.
  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, bandwidthTest.exe, is available in Debug folder of build-bandwidthTest-VS2015 folder.

CMake 3.17 CMakeLists.txt for Mandelbrot project

  1. Generate Mandelbrot folder on desktop of Windows 10.
    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:\ProgramData\NVIDIA Corporation\CUDA Samples\v8.0\2_Graphics\Mandelbrot into src folder.
  3. Paste the following CMake 3.17 file into CMakeLists.txt
    # CMakeLists.txt to build Mandelbrot
    cmake_minimum_required(VERSION 3.17)
    
    project(Mandelbrot VERSION 1.0
            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:/ProgramData/NVIDIA Corporation/CUDA Samples/v8.0/common/inc"
    )
    
    # Specify target & external glew64.lib library paths
    target_link_directories(
        ${PROJECT_NAME}
        PRIVATE
        "C:/ProgramData/NVIDIA Corporation/CUDA Samples/v8.0/common/lib/x64"
    )
    
    # For linking ...
    # Specify target & libraries to link it with
    target_link_libraries(
        ${PROJECT_NAME}
        PUBLIC
        glew64
    )

Mandelbrot project with Visual Studio 14 2015 generator

  1. Generate build-Mandelbrot-VS2015 folder on desktop of Windows 10.
  2. Launch CMake 3.17 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-VS2015 folder in Where is build binaries.
    Click Configure button.
  4. 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.
  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-VS2015 folder.

  8. Copy and paste the two files glew64.dll and freeglut.dll from the folder C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\extras\demo_suite into Debug folder of build-Mandelbrot-VS2015 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. Jérémy Fix: Tutoriel CMake
  5. CMake: CMake tutoriel
  6. GitBook: An introduction to modern CMake; A simple example
  7. rix0r: The ultimate guide to modern CMake
  8. Deniz Bahadir: More modern CMake - Working with CMake 3.12 and later
  9. YouTube: CppCon 2017: Mathieu Ropert “Using Modern CMake patterns to enforce a good modular design”
  10. GitHub: Effective modern CMake
  11. Daniel Pfeifer: CMake - introduction and best practices
  12. Kuba Sejdak: Modern CMake is like inheritance
  13. Nick Winder: Modern CMake tips
  14. Kohei Otsuka: Simple modern CMake tutorial part 1
  15. Pablo Arias: It's time to do CMake right
  16. Mario Badr: Header-only libraries
  17. LLVM: CMake primer
  18. John Lamp: CMake tutorial
  19. Derek Molloy: Introduction to CMake by example
  20. Mirko Kiefer: CMake by example
  21. Dmerej's blog: Let's build Chuck Norris! - Part 1: CMake and Ninja
  22. Android Studio: Configure CMake
  23. Visual Servoing Platform Tutorial: How to create and build a project that uses ViSP and CMake on Unix or Windows
  24. Selective Intellect: How to use CMake to add third party libraries to your project
  25. Microsoft: Projets CMake dans Visual Studio 2015
  26. Kitware Robot: Generator specific information
  27. Preshing on Programming: How to build a CMake-based project
  28. Javier V. Gómez: How to configure a C/C++ project with Eclipse and CMake
  29. StackOverflow: How to configure Eclipse CDT for Cmake?
    In Eclipse-CDT you do not create Cmake project but you import Cmake project.
  30. Packt Publishing Limited: Importing a CMake project into Eclipse CDT
  31. johnnado: Build with CMake in Eclipse
  32. gitlab.kitware: How to find libraries
  33. Simplify C++!: Hello CMake!
  34. ROS: catkin/CMakeLists.txt
    What does find_package() do?
  35. deal.II: How to use CMake to configure your projects with deal.II
  36. GitHub: How to set include directories in CMake
  37. StackOverflow: How do I add a library path in cmake?

References CUDA

  1. Code Yarns: How to build CUDA programs using CMake
  2. Nvidia developer blog: Building cross-platform CUDA applications with CMake
  3. Thomas Gredin: Mise en place d'un environnement de développement CUDA/C++ sur Windows
  4. CMake: FindCUDAToolkit
  5. Attila Krasznahorkay: Building CUDA code
  6. 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
    )
  7. Jared Casper: Provide target libraries for cuda libraries
  8. Siyuan Liu: CUDA as a language in CMake
  9. JavaEar: Obtaining the CUDA include dir in C++ targets with native-CUDA-support CMake?
  10. Robert Maynard: Build systems: Combining CUDA and modern CMake
  11. Luke Yeager: Example of how to use CUDA with CMake >= 3.8
  12. Jonathan R. Madsen: Build systems - GPU offloading
  13. Justin Francis: Detecting Cuda architecture required by CMake using NVCC
  14. developpez: Cmake pour CUDA project
  15. Benjamin Charlier: Find CUDA and GPUs
  16. Narkive: How do you allow CMAKE_CUDA_COMPILER to be optional via project LANGUAGE?
  17. StackOverrun: Cmake - Ajouter toutes les bibliothèques CUDA
  18. Jean-Philippe Lang : Install local NVIDIA GPU Computing SDK
  19. Pierre Aubert: Le fichier CMakeLists.txt
  20. 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.
  21. CLion: Working with CUDA projects
  22. 5KK73GPU2011: CMake
  23. StackOverflow: How to compile C++ as CUDA using CMake
  24. 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 June 30, 2020
Copyright © 2002-2020 pascal-man.com. All rights reserved.