<div dir="ltr">All,<br><br>Thanks for all the help, I'm getting closer. My current approach does this....<br><br>CMAKE_MINIMUM_REQUIRED( VERSION 2.8 )<br>INCLUDE( ExternalProject )<br><br><div>SET( VS_MAKEFILE_ZIP vsnet-makefiles.0.85.zip )<br>
<br>IF( MSVC )<br> IF( MSVC_VERSION EQUAL 1200 )<br> SET( VS_TOOLS_PATH $ENV{VS60COMNTOOLS} )<br> SET( VS_ENV_BAT ${VS_TOOLS_PATH}vsvars32.bat )<br> ELSEIF( MSVC_VERSION EQUAL 1300 )<br> SET( VS_TOOLS_PATH $ENV{VS70COMNTOOLS} )<br>
SET( VS_ENV_BAT ${VS_TOOLS_PATH}vsvars32.bat )<br> ELSEIF( MSVC_VERSION EQUAL 1310 )<br> SET( VS_TOOLS_PATH $ENV{VS71COMNTOOLS} )<br> SET( VS_ENV_BAT ${VS_TOOLS_PATH}vsvars32.bat )<br> ELSEIF( MSVC_VERSION EQUAL 1400 )<br>
SET( VS_TOOLS_PATH $ENV{VS80COMNTOOLS} )<br> SET( VS_ENV_BAT ${VS_TOOLS_PATH}vsvars32.bat )<br> ELSEIF( MSVC_VERSION EQUAL 1500 )<br> SET( VS_TOOLS_PATH $ENV{VS90COMNTOOLS} )<br> SET( VS_ENV_BAT ${VS_TOOLS_PATH}vsvars32.bat )<br>
ELSEIF( MSVC_VERSION EQUAL 1600 )<br> SET( VS_TOOLS_PATH $ENV{VS100COMNTOOLS} )<br> SET( VS_ENV_BAT ${VS_TOOLS_PATH}vsvars32.bat )<br> ELSEIF( MSVC_VERSION EQUAL 1700 )<br> SET( VS_TOOLS_PATH $ENV{VS110COMNTOOLS} )<br>
SET( VS_ENV_BAT ${VS_TOOLS_PATH}VsDevCmd.bat )<br> ELSEIF( MSVC_VERSION EQUAL 1800 )<br> SET( VS_TOOLS_PATH $ENV{VS120COMNTOOLS} )<br> SET( VS_ENV_BAT ${VS_TOOLS_PATH}VsDevCmd.bat )<br> ENDIF( MSVC_VERSION EQUAL 1200 )<br>
ENDIF ( MSVC )<br><br>file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/opts.txt<br>"R<br>V")<br><br>file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/runthis.bat<br>"call \"${VS_ENV_BAT}\"<br>gmake < opts.txt")<br>
<br>ExternalProject_Add( FLTK<br> URL ${CMAKE_SOURCE_DIR}/fltk-1.3.2-source.tar<br> UPDATE_COMMAND<br> ${CMAKE_COMMAND} -E copy_if_different<br> ${CMAKE_SOURCE_DIR}/${VS_MAKEFILE_ZIP}<br> <SOURCE_DIR>/${VS_MAKEFILE_ZIP}<br>
COMMAND<br> ${CMAKE_COMMAND} -E tar -xzf <SOURCE_DIR>/${VS_MAKEFILE_ZIP}<br> COMMAND<br> ${CMAKE_COMMAND} -E copy_if_different<br> ${CMAKE_CURRENT_BINARY_DIR}/opts.txt<br> <SOURCE_DIR>/opts.txt<br>
COMMAND<br> ${CMAKE_COMMAND} -E copy_if_different<br> ${CMAKE_CURRENT_BINARY_DIR}/runthis.bat<br> <SOURCE_DIR>/runthis.bat<br><br> PATCH_COMMAND ""<br> CONFIGURE_COMMAND runthis.bat<br> BUILD_COMMAND ""<br>
INSTALL_COMMAND ""<br> BUILD_IN_SOURCE 1<br>)<br><br><br>It doesn't fully work.</div><div><br></div><div>-- I create the opts.txt and runthis.bat files in CMAKE_CURRENT_BINARY_DIR and then copy them to <SOURCE_DIR>. I couldn't figure out how to write them within ExternalProject_Add and <SOURCE_DIR> doesn't exist before unless I want to reset its value. Suggestions Welcome.</div>
<div><br></div><div>-- opts.txt and runthis.bat end up where I want them and contain what I want.<br><br>-- If you double-click runthis.bat, it successfully builds FLTK.</div><div><br></div><div>-- However, running 'runthis.bat' from inside ExternalProject fails. I've tried 'cmd runthis.bat' '<SOURCE_DIR>/runthis.bat' and a few other things, none work.</div>
<div><br></div><div>I think it may be a problem with the command to run the batch program doesn't create a new environment, or doesn't keep the environment variables set by vsvars32.bat.</div><div><br></div><div>Suggestions Welcome.</div>
<div><br></div><div>Rob</div><div><br></div><div>P.S. The mess of IF code to detect the MSVC version and use the environment variable has not been vetted and is mostly a guess at this point. From all the googling I could do, it is probably closeish to right.</div>
<div><br></div><div>P.P.S. vsvarsall.bat Is special because it lets you set 32/64/arm target and also 32/64 host environments. I would like to support 32/64 target, but you can't set target without knowing the host environment. Is there a CMake way to detect whether the Visual Studio host environment is 32/64 bit?</div>
<div><br></div><div><br><br><br>On Thu, Jan 9, 2014 at 10:48 AM, Rob McDonald <<a href="mailto:rob.a.mcdonald@gmail.com">rob.a.mcdonald@gmail.com</a>> wrote:<br>><br>> Correct, this is one of the concerns that makes it more complex than just searching for the first vcvarsall.bat you come to.<br>
><br>> I'd like to match up the vcvarsall to the version of visual studio currently in use by CMake.<br>><br>> I think there are now enough pieces that I can write a CMake 'FindVSEnvironment.cmake'. While I can't test it for a large number of MSVC versions, I'll post it and hopefully others can help out.<br>
><br>> Rob<br>><br>><br>> On Thu, Jan 9, 2014 at 6:44 AM, John Drescher <<a href="mailto:drescherjm@gmail.com">drescherjm@gmail.com</a>> wrote:<br>>><br>>> > Why not just write your own batch ('buildit.bat') file that does:<br>
>> ><br>>> > call vcvarsall.bat<br>>> > nmake<br>>> ><br>>> > (or whatever the command to build in the VS command prompt is...)<br>>> ><br>>> > And then your command to build is:<br>
>> ><br>>> > C:/full/path/to/buildit.bat<br>>> ><br>>> > It's presumably in a Windows-specific chunk of your CMakeLists anyway, so<br>>> > that should work fairly simply.<br>
>><br>>> I think the part of problem would be figuring out what vcvarsall.bat<br>>> to run especially if you have more than 1 version of Visual Studio.<br>>><br>>> John<br>><br>><br></div>
</div>