Skip to content
This repository has been archived by the owner on Jun 27, 2022. It is now read-only.

Fix compilation with cmake on Windows #28

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

nikolaitasev
Copy link

Here are some fixes that make it possible to compile with cmake and msvc on Windows.

Nikolai Tasev added 3 commits June 6, 2017 17:37
When compiling on Windows with MSVC this option breaks the compilation.
Maybe this selection should be removed altogether and let the user
select its compiler when needed.
@FantasyVR
Copy link

I update the CMakeLists.txt based on your pull request. But when I build project on visual studio 2017 and cuda 10.0. I get the following errors:

1>------ Build started: Project: ZERO_CHECK, Configuration: Debug x64 ------
2>------ Build started: Project: HW1, Configuration: Debug x64 ------
2>Building NVCC (Device) object ProblemSets/ProblemSet1/CMakeFiles/HW1.dir/Debug/HW1_generated_student_func.cu.obj
2>CMake Error at HW1_generated_student_func.cu.obj.Debug.cmake:219 (message):
2>  Error generating
2>  F:/OpenSource/cs344/build/ProblemSets/ProblemSet1/CMakeFiles/HW1.dir//Debug/HW1_generated_student_func.cu.obj
2>
2>
2>D:\Microsoft Visual Studio\2017\Common7\IDE\VC\VCTargets\Microsoft.CppCommon.targets(209,5): error MSB6006: "cmd.exe" exited with code 1.
2>Done building project "HW1.vcxproj" -- FAILED.
========== Build: 1 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

The CMakeLists.txt is as below:

############################################################################
# <summary> CMakeLists.txt for OpenCV and CUDA. </summary>
# <date>    2012-02-07          </date>
# <author>  Quan Tran Minh. edit by Johannes Kast, Michael Sarahan </author>
# <email>   quantm@unist.ac.kr  kast.jo@googlemail.com msarahan@gmail.com</email>
############################################################################

cmake_minimum_required(VERSION 2.6 FATAL_ERROR)
project(cs344)

find_package(OpenCV REQUIRED)
find_package(CUDA REQUIRED)

link_libraries(${OpenCV_LIBS} )

set (EXECUTABLE_OUTPUT_PATH "${CMAKE_SOURCE_DIR}/bin/")

if(CUDA_FOUND)
  # compared to class settings, we let NVidia's FindCUDA CMake detect 
  # whether to build x64.  We tell it to support most devices, though, 
  # to make sure more people can easily run class code without knowing 
  # about this compiler argument
  set(CUDA_NVCC_FLAGS "-gencode;arch=compute_75,code=sm_75;")  #GTX 2080 Ti

  # add -Wextra compiler flag for gcc compilations
  if (UNIX)
    set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} "-ccbin /usr/bin/clang")
    set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} "-Xcompiler -Wextra")
    set(CMAKE_CXX_FLAGS "-stdlib=libstdc++")
  endif (UNIX)

  # add debugging to CUDA NVCC flags.  For NVidia's NSight tools.
  set(CUDA_NVCC_FLAGS_DEBUG ${CUDA_NVCC_FLAGS_DEBUG} "-G")

  add_subdirectory (ProblemSets)

else(CUDA_FOUND)
  message("CUDA is not installed on this system.")
endif()

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
2 participants