cmakeconverter icon indicating copy to clipboard operation
cmakeconverter copied to clipboard

$(SolutionDir) not replaced in AdditionalOptions for Compile Options

Open alandtse opened this issue 2 years ago • 0 comments

Describe the bug

  1. A clear and concise description of what the bug is. At least the variable $(SolutionsDir) is not being replaced when in an AdditionalOptions field under ClCompile . This results in an invalid syntax warning for cmake. I did not test if other variable replacements worked.
CMake Warning (dev) at CMakeLists.txt:3589:
  Syntax Warning in cmake code at column 32

  Argument not separated from preceding token by whitespace.
This warning is for project developers.  Use -Wno-dev to suppress it.

Specifically, it is generating this option

       /external:I;
        "$(SolutionDir)/sksevr";

instead of

        /external:I"${CMAKE_SOURCE_DIR}/sksevr";`
  1. Which is version of converter. python? 2.1.0, python 3.9.6
  2. Increase warnings level (-w4) and attach verbose (-v) output log to help investigate what was happen. Use one thread to get the logs to make them easy to read(-j1).
PS C:\Users\Alan\source\repos\CommonLibVR> cmake-converter -s .\CommonLibVR.sln -w4 -j1

0.000000 processes count = 1
0.000000 warnings level = 4


0.002965 1> Conversion started: Project CommonLibVR
0.012940 1> WARN L4 : file:/C:/Users/Alan/source/repos/CommonLibVR/CommonLibVR.vcxproj(21): ('Release', 'x64') : /Fa option is ignored. Too hard to handle for different CMake generators.
0.013938 1> WARN L3 : file:/C:/Users/Alan/source/repos/CommonLibVR/CommonLibVR.vcxproj(26): ('Release', 'x64') : No handler for <EnableUnitySupport> node.
0.014933 1> WARN L4 : file:/C:/Users/Alan/source/repos/CommonLibVR/CommonLibVR.vcxproj(28): ('Debug', 'x64') : /Fa option is ignored. Too hard to handle for different CMake generators.
0.014933 1> WARN L3 : file:/C:/Users/Alan/source/repos/CommonLibVR/CommonLibVR.vcxproj(32): ('Debug', 'x64') : No handler for <EnableUnitySupport> node.
0.015930 1> WARN L3 : file:/C:/Users/Alan/source/repos/CommonLibVR/CommonLibVR.vcxproj(49): ('Debug', 'x64') : No handler for <PostBuildEventUseInBuild> node.
0.015930 1> WARN L3 : file:/C:/Users/Alan/source/repos/CommonLibVR/CommonLibVR.vcxproj(54): ('Release', 'x64') : No handler for <PostBuildEventUseInBuild> node.
0.018923 1> WARN L3 : file:/C:/Users/Alan/source/repos/CommonLibVR/CommonLibVR.vcxproj(67): ('Debug', 'x64') : No handler for <ForcedIncludeFiles> node.
0.020917 1> WARN L3 : file:/C:/Users/Alan/source/repos/CommonLibVR/CommonLibVR.vcxproj(74): ('Debug', 'x64') : No handler for <EnforceTypeConversionRules> node.
0.021943 1> WARN L3 : file:/C:/Users/Alan/source/repos/CommonLibVR/CommonLibVR.vcxproj(76): ('Debug', 'x64') : No handler for <UseFullPaths> node.
0.021943 1> WARN L3 : file:/C:/Users/Alan/source/repos/CommonLibVR/CommonLibVR.vcxproj(78): ('Debug', 'x64') : No handler for <EnableModules> node.
0.021943 1> WARN L3 : file:/C:/Users/Alan/source/repos/CommonLibVR/CommonLibVR.vcxproj(80): ('Debug', 'x64') : No handler for <TreatSpecificWarningsAsErrors> node.
0.022939 1> WARN L3 : file:/C:/Users/Alan/source/repos/CommonLibVR/CommonLibVR.vcxproj(82): ('Debug', 'x64') : No handler for <UndefinePreprocessorDefinitions> node.
0.022939 1> WARN L3 : file:/C:/Users/Alan/source/repos/CommonLibVR/CommonLibVR.vcxproj(87): ('Debug', 'x64') : No handler for <ModuleDefinitionFile> node.
0.026928 1> WARN L3 : file:/C:/Users/Alan/source/repos/CommonLibVR/CommonLibVR.vcxproj(123): ('Release', 'x64') : No handler for <ForcedIncludeFiles> node.
0.026928 1> WARN L3 : file:/C:/Users/Alan/source/repos/CommonLibVR/CommonLibVR.vcxproj(131): ('Release', 'x64') : No handler for <EnforceTypeConversionRules> node.
0.027899 1> WARN L3 : file:/C:/Users/Alan/source/repos/CommonLibVR/CommonLibVR.vcxproj(132): ('Release', 'x64') : No handler for <UseFullPaths> node.
0.027899 1> WARN L3 : file:/C:/Users/Alan/source/repos/CommonLibVR/CommonLibVR.vcxproj(134): ('Release', 'x64') : No handler for <EnableModules> node.
0.027899 1> WARN L3 : file:/C:/Users/Alan/source/repos/CommonLibVR/CommonLibVR.vcxproj(135): ('Release', 'x64') : No handler for <TreatSpecificWarningsAsErrors> node.
0.027899 1> WARN L3 : file:/C:/Users/Alan/source/repos/CommonLibVR/CommonLibVR.vcxproj(137): ('Release', 'x64') : No handler for <UndefinePreprocessorDefinitions> node.
0.028896 1> WARN L3 : file:/C:/Users/Alan/source/repos/CommonLibVR/CommonLibVR.vcxproj(143): ('Release', 'x64') : No handler for <ModuleDefinitionFile> node.
3.839210 1> Conversion done   : Project CommonLibVR (20 warnings)
3.844223 Conversion of C:\Users\Alan\source\repos\CommonLibVR\CommonLibVR.sln finished (20 warnings)

Now you may run cmake like following sample:

cmake -S "C:\Users\Alan\source\repos\CommonLibVR" -B "C:\Users\Alan\source\repos\CommonLibVR\build" -G "Visual Studio 15 2017 Win64"
PS C:\Users\Alan\source\repos\CommonLibVR>
  1. Also the sample of input xml project(or full solution (might be without code)) and output CMakeLists part wrong content is required. I don't have much time for digging into it. So with more info I can help you easily.

I am converting https://github.com/lfrazer/CommonLibVR. The specific line is https://github.com/lfrazer/CommonLibVR/blob/master/CommonLibVR.vcxproj#L84

The CMakeLists.txt with the error is (--> for specific line):

    target_compile_options(${PROJECT_NAME} PRIVATE
        $<$<CONFIG:Debug>:
            /GL-;
            /Od;
            /RTC1;
            /fp:except;
            /guard:cf;
            /Zc:inline-
        >
        $<$<CONFIG:Release>:
            /GL;
            /O2;
            /Oi;
            /Zc:inline
        >
        /permissive-;
        /std:c++17;
        /Gy;
        /WX-;
        /Zi;
        /TP;
        /experimental:external;
        /external:anglebrackets;
        /external:I;
-->        "$(SolutionDir)/sksevr";
        /external:W0;
        ${DEFAULT_CXX_EXCEPTION_HANDLING};
        /Y-
    )

It also appears that it's breaking the option into two lines.

       /external:I;
        "$(SolutionDir)/sksevr";

instead of

        /external:I"${CMAKE_SOURCE_DIR}/sksevr";`

To Reproduce Steps to reproduce the behavior:

  1. git clone https://github.com/lfrazer/CommonLibVR.git
  2. cd CommonLibVR
  3. cmake-converter -s .\CommonLibVR.sln
  4. cmake . -B out
  5. See syntax error

Expected behavior A clear and concise description of what you expected to happen. $(SolutionsDir) variable should be replaced with ${CMAKE_SOURCE_DIR}/ and the option should not be broken in two.

Additional context Add any other context about the problem here. The cmake conversion is failing probably for other reasons I am debugging, but for now wanted to report the obvious issue. Thanks for building this tool!

alandtse avatar Aug 15 '21 07:08 alandtse