"CMAKE" doesn't create "Debug" or "Release" output folders

My .vcxproj file had this segment, which includes x64/Debug and x64/Release for Configuration and Platform. I am working on Windows machine

  <ItemGroup Label="ProjectConfigurations">
    <ProjectConfiguration Include="Debug|x64">
      <Configuration>Debug</Configuration>
      <Platform>x64</Platform>
    </ProjectConfiguration>
    <ProjectConfiguration Include="Release|x64">
      <Configuration>Release</Configuration>
      <Platform>x64</Platform>
    </ProjectConfiguration>
..........
      </ItemGroup>

I now tried to create CMakeLists.txt

cmake_minimum_required(VERSION 3.5)

project(LogMsg)

# Set the project source files
set(SOURCES
    LogMsgMain.rc
    LogMsg.h
)

# Add executable target
add_executable(LogMsg ${SOURCES})

# Set the configuration-specific outputs
set_target_properties(LogMsg PROPERTIES
    RUNTIME_OUTPUT_DIRECTORY_DEBUG "${CMAKE_CURRENT_SOURCE_DIR}/Debug"
    RUNTIME_OUTPUT_DIRECTORY_RELEASE "${CMAKE_CURRENT_SOURCE_DIR}/Release"
)

# Add include directories
target_include_directories(LogMsg PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})

# Specify custom build commands
add_custom_command(TARGET LogMsg POST_BUILD
    COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_CURRENT_SOURCE_DIR}/LogMsg.rc" "$<TARGET_FILE_DIR:LogMsg>"
    COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_CURRENT_SOURCE_DIR}/LogMsg.h" "$<TARGET_FILE_DIR:LogMsg>"
    COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_CURRENT_BINARY_DIR}/MSG00001.bin" "$<TARGET_FILE_DIR:LogMsg>"
)

After that I run cmake command: Tried two approaches:

cmake -S . -B . -G "Visual Studio 17 2022" 
cmake -S . -B . -G "Visual Studio 17 2022" -DCMAKE_BUILD_TYPE=Debug

But in both cases I am not getting x64/Debug and Release folders with my .lib file.

Can someone take a look what I am missing in configuration of the CMakeLists?

UPDATE My new CMakeLists.txt file is the following:

cmake_minimum_required(VERSION 3.5)

project(FALogMsg)

# Set the project source files
set(SOURCES
    FALogMsg.cpp
    FALogMsgMain.rc
    FALogMsg.h
    resource.h
    stdafx.h
)

# Add executable target
add_library(FALogMsg ${SOURCES})

# Set the configuration-specific outputs
set_target_properties(FALogMsg PROPERTIES
    RUNTIME_OUTPUT_DIRECTORY_DEBUG "${CMAKE_CURRENT_SOURCE_DIR}/x64/Debug"
    RUNTIME_OUTPUT_DIRECTORY_RELEASE "${CMAKE_CURRENT_SOURCE_DIR}/x64/Release"
)

# Add include directories
target_include_directories(FALogMsg PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})

# Specify custom build commands
add_custom_command(TARGET FALogMsg POST_BUILD
    COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_CURRENT_SOURCE_DIR}/FALogMsg.rc" "$<TARGET_FILE_DIR:FALogMsg>"
    COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_CURRENT_SOURCE_DIR}/FALogMsg.h" "$<TARGET_FILE_DIR:FALogMsg>"
    COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_CURRENT_BINARY_DIR}/MSG00001.bin" "$<TARGET_FILE_DIR:FALogMsg>"
)

Error:

C:\Projects..\base\LogMsg>cmake --build build --config Release MSBuild version 17.6.3+07e294721 for .NET Framework

Building Custom Rule C:/Projects/../base/LogMsg/CMakeLists.txt
LogMsg.cpp LogMsg.vcxproj -> C:\Projects\AccurevMigration\Projects\workspace\OTM_PlaceHolder_Work_v2\base\LogMsg\build\Release\LogMsg.lib Error copying file (if different) from "C:/Projects/AccurevMigration/Projects/workspace/OTM_PlaceHolder_Work_v2/base/LogMsg/build/MSG00001.bin" to "C:/Projects/AccurevMigration/Projects/workspace/OTM_PlaceH
older_Work_v2/base/LogMsg/build/Release". C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(160,5): error MSB3073: The command "setlocal [C:\Projects\AccurevMigration\Projects\workspace\OTM _PlaceHolder_Work_v2\base\LogMsg\build\LogMsg.vcxproj] C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(160,5): error MSB3073: "C:\Program Files\CMake\bin\cmake.exe" -E copy_if_different C:/Projects/Ac curevMigration/Projects/workspace/OTM_PlaceHolder_Work_v2/base/LogMsg/LogMsg.rc C:/Projects/AccurevMigration/Projects/workspace/OTM_PlaceHolder_Work_v2/base/LogMsg/build/Release [C:\Projects\AccurevMigrat ion\Projects\workspace\OTM_PlaceHolder_Work_v2\base\LogMsg\build\LogMsg.vcxproj] C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(160,5): error MSB3073: if %errorlevel% neq 0 goto :cmEnd [C:\Projects\AccurevMigration\Projects\w orkspace\OTM_PlaceHolder_Work_v2\base\LogMsg\build\LogMsg.vcxproj] C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(160,5): error MSB3073: "C:\Program Files\CMake\bin\cmake.exe" -E copy_if_different C:/Projects/Ac curevMigration/Projects/workspace/OTM_PlaceHolder_Work_v2/base/LogMsg/LogMsg.h C:/Projects/AccurevMigration/Projects/workspace/OTM_PlaceHolder_Work_v2/base/LogMsg/build/Release [C:\Projects\AccurevMigrati on\Projects\workspace\OTM_PlaceHolder_Work_v2\base\LogMsg\build\LogMsg.vcxproj] C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(160,5): error MSB3073: if %errorlevel% neq 0 goto :cmEnd [C:\Projects\AccurevMigration\Projects\w orkspace\OTM_PlaceHolder_Work_v2\base\LogMsg\build\LogMsg.vcxproj] C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(160,5): error MSB3073: "C:\Program Files\CMake\bin\cmake.exe" -E copy_if_different C:/Projects/Ac curevMigration/Projects/workspace/OTM_PlaceHolder_Work_v2/base/LogMsg/build/MSG00001.bin C:/Projects/AccurevMigration/Projects/workspace/OTM_PlaceHolder_Work_v2/base/LogMsg/build/Release [C:\Projects\Accure vMigration\Projects\workspace\OTM_PlaceHolder_Work_v2\base\LogMsg\build\LogMsg.vcxproj] C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(160,5): error MSB3073: if %errorlevel% neq 0 goto :cmEnd [C:\Projects\AccurevMigration\Projects\w orkspace\OTM_PlaceHolder_Work_v2\base\LogMsg\build\LogMsg.vcxproj] C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(160,5): error MSB3073: :cmEnd [C:\Projects\AccurevMigration\Projects\workspace\OTM_PlaceHolder_Wo rk_v2\base\LogMsg\build\LogMsg.vcxproj] C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(160,5): error MSB3073: endlocal & call :cmErrorLevel %errorlevel% & goto :cmDone [C:\Projects\Acc urevMigration\Projects\workspace\OTM_PlaceHolder_Work_v2\base\LogMsg\build\LogMsg.vcxproj] C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(160,5): error MSB3073: :cmErrorLevel [C:\Projects\AccurevMigration\Projects\workspace\OTM_PlaceHo lder_Work_v2\base\LogMsg\build\LogMsg.vcxproj] C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(160,5): error MSB3073: exit /b %1 [C:\Projects\AccurevMigration\Projects\workspace\OTM_PlaceHolde r_Work_v2\base\LogMsg\build\LogMsg.vcxproj] C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(160,5): error MSB3073: :cmDone [C:\Projects\AccurevMigration\Projects\workspace\OTM_PlaceHolder_W ork_v2\base\LogMsg\build\LogMsg.vcxproj] C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(160,5): error MSB3073: if %errorlevel% neq 0 goto :VCEnd [C:\Projects\AccurevMigration\Projects\w orkspace\OTM_PlaceHolder_Work_v2\base\LogMsg\build\LogMsg.vcxproj] C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(160,5): error MSB3073: :VCEnd" exited with code 1. [C:\Projects\AccurevMigration\Projects\workspa ce\OTM_PlaceHolder_Work_v2\base\LogMsg\build\LogMsg.vcxproj]



Comments

Popular posts from this blog

Today Walkin 14th-Sept

Spring Elasticsearch Operations

Hibernate Search - Elasticsearch with JSON manipulation