title: NMAKE : fatal error U1077: cl.exe and nmake.exe return code '0x2'
body: <p>I'm trying to build a c++ project using cmake and CLion but I get a few errors I can't understand:</p>
  
  <pre><code>"C:\Program Files\JetBrains\CLion 2019.2.5\bin\cmake\win\bin\cmake.exe" --build C:\Users\username\project-name\cmake-build-debug --target all_tests
  Scanning dependencies of target all_tests
  [  0%] Building CXX object CMakeFiles/all_tests.dir/tests/all_tests.cpp.obj
  all_tests.cpp
  C:\PROGRA~2\Boost\include\BOOST-~1\boost/test/impl/compiler_log_formatter.ipp(64): warning C4273: 'boost::unit_test::output::compiler_log_formatter::log_start': inconsistent dll link
  C:\PROGRA~2\Boost\include\BOOST-~1\boost/test/output/compiler_log_formatter.hpp(37): note: see previous definition of 'log_start'
  C:\PROGRA~2\Boost\include\BOOST-~1\boost/test/impl/compiler_log_formatter.ipp(76): warning C4273: 'boost::unit_test::output::compiler_log_formatter::log_finish': inconsistent dll link
  C:\PROGRA~2\Boost\include\BOOST-~1\boost/test/output/compiler_log_formatter.hpp(38): note: see previous definition of 'log_finish'
  // ...
  // ... many more warnings like these
  // ...
  C:\PROGRA~2\Boost\include\BOOST-~1\boost/test/impl/unit_test_parameters.ipp(759): warning C4273: 'boost::unit_test::runtime_config::save_pattern': inconsistent dll link
  C:\PROGRA~2\Boost\include\BOOST-~1\boost/test/unit_test_parameters.hpp(93): note: see previous definition of 'save_pattern'
  NMAKE : fatal error U1077: 'C:\PROGRA~2\MICROS~3\2017\BUILDT~1\VC\Tools\MSVC\1416~1.270\bin\Hostx86\x86\cl.exe' : return code '0x2'
  Stop.
  NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.16.27023\bin\HostX86\x86\nmake.exe"' : return code '0x2'
  Stop.
  NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.16.27023\bin\HostX86\x86\nmake.exe"' : return code '0x2'
  Stop.
  NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.16.27023\bin\HostX86\x86\nmake.exe"' : return code '0x2'
  Stop.
  </code></pre>
  
  <p>The cmake file I use is the following:</p>
  
  <pre><code>cmake_minimum_required(VERSION 3.9)
  project(project_name)
  
  set(CMAKE_CXX_STANDARD 11)
  
  # private lib
  add_library(lib INTERFACE)
  target_include_directories(lib INTERFACE src/utilities)
  
  # boost
  set(BOOST_ROOT "C:\\Program Files\\Boost")
  find_package(Boost CONFIG 1.71.0)
  if(Boost_FOUND)
      message("FOUND")
      include_directories(${Boost_INCLUDE_DIR})
  endif()
  
  SET(MAIN "...")
  SET(TESTS "...")
  
  add_executable(all_tests tests/all_tests.cpp ${MAIN} ${TESTS})
  target_link_libraries(all_tests lib)
  
  </code></pre>
  
  <p>Please note that this same project works on my mac but when I try to build it in windows 10 it gives this error, so what's the problem here?</p>
  
  <p>EDIT:</p>
  
  <p>all_tests.cpp:</p>
  
  <pre><code>#define BOOST_TEST_DYN_LINK
  
  #include &lt;boost/test/unit_test.hpp&gt;
  #include &lt;boost/test/included/unit_test.hpp&gt;
  
  // initialization function:
  bool init_unit_test() {
      return true;
  }
  
  // entry point:
  int main(int argc, char* argv[], char* envp[]) {
      return boost::unit_test::unit_test_main( &amp;init_unit_test, argc, argv );
  }
  </code></pre>
  
  <p>Example test suite:</p>
  
  <pre><code>#define BOOST_TEST_DYN_LINK
  #include &lt;boost/test/unit_test.hpp&gt;
  #include "../../src/path/to/header.hpp"
  
  BOOST_AUTO_TEST_SUITE( Suite1 )
  
      BOOST_AUTO_TEST_CASE( Test1 ) {
          auto res = header_class::function1();
          BOOST_CHECK_EQUAL(res, expected_result);
      }
  
      BOOST_AUTO_TEST_CASE( Test2 ) {
          auto res = header_class::function2();
          BOOST_CHECK_EQUAL(res, expected_result);
      }
  
  BOOST_AUTO_TEST_SUITE_END()
  </code></pre>
  
  <p>I'm pretty sure that the code inside test cases is correct and it's not causing the problem.</p>