abdes/cryptopp-cmake

Facing build errors

Closed this issue · 6 comments

After switching to this cmake script of cryptopp, I'm facing the following include error:
image

abdes commented

Could you share a bit more about how you are using the project?

  • How are you including it in your cmake build? provide the code snippet that does that
  • Your CMakeCache.txt if possible,
  • Ultimately, if your project is OpenSource, please share with us the repo location so we can check it

I'm trying to upgrade Citra's cryptopp to this repo, since the older one had issues when building with clang-cl. Here's the commit for reference: https://github.com/GPUCode/citra/commit/c5f0c77706369dc3e012b74b7719172fed439e8a. Note that DISABLE_RDRAND is set to TRUE as a temporary workaround to bypass this error

abdes commented

I noticed, you still have cryptopp in your vcpkg.json file (which pulls the old cryptopp-cmake) and you have cryptopp (the new one) in your externals. Could that be the problem?

I tried to build your commit on Windows, and I face problems with vcpkg and fmtlib before I compete the configure...

-- Performing Test FMT_HAS_VARIANT - Success
-- Required features: cxx_variadic_templates
-- Looking for _strtod_l
-- Looking for _strtod_l - found
CMake Error at externals/vcpkg/scripts/buildsystems/vcpkg.cmake:618 (_add_library):
  _add_library cannot create ALIAS target "fmt::fmt" because another target
  with the same name already exists.
Call Stack (most recent call first):
  externals/dynarmic/externals/fmt/CMakeLists.txt:240 (add_library)


CMake Error at externals/vcpkg/scripts/buildsystems/vcpkg.cmake:618 (_add_library):
  _add_library cannot create ALIAS target "fmt::fmt-header-only" because
  another target with the same name already exists.
Call Stack (most recent call first):
  externals/dynarmic/externals/fmt/CMakeLists.txt:296 (add_library)

abdes commented

Can you also please copy paste the output of a clean configure phase for cryptopp?

I am running into the same issue on Windows. These are my build steps:

  1. git clone https://github.com/abdes/cryptopp-cmake.git
  2. cd cryptopp-cmake
  3. mkdir build
  4. cd build
  5. cmake ..
  6. cmake --build .

Here's the CMakeCache.txt

Output:

C:\Users\Admin\Source\Repos\cryptopp-cmake\build>cmake ..
-- Building for: Visual Studio 17 2022
=> Project : cryptopp v8.7.0 (c7fa777bb92d)
-- Selecting Windows SDK version 10.0.22000.0 to target Windows 10.0.22622.
-- The CXX compiler identification is MSVC 19.33.31629.0
-- The C compiler identification is MSVC 19.33.31629.0
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.33.31629/bin/Hostx64/x64/cl.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.33.31629/bin/Hostx64/x64/cl.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Found Git: C:/Program Files/Git/cmd/git.exe (found version "2.37.0.windows.1")
-- downloading/updating cryptopp
-- cryptopp directory not found, cloning...
Cloning into 'C:/Users/Admin/Source/Repos/cryptopp-cmake/build/_deps/cryptopp'...
--
Switched to a new branch 'tag_CRYPTOPP_8_7_0'
--
-- Crypto++ auto fetched at: C:/Users/Admin/Source/Repos/cryptopp-cmake/build/_deps/cryptopp
-- Adding install integration test: int-install-default
-- Adding install integration test: int-install-prefix
=> Module : cryptopp
-- [cryptopp] CMake version 3.23.1
-- [cryptopp] System Windows
-- [cryptopp] Processor AMD64
-- [cryptopp] Target architecture detected as: x86_64 -> CRYPTOPP_AMD64
-- Looking for C++ include winapifamily.h
-- Looking for C++ include winapifamily.h - found
-- The ASM_MASM compiler identification is MSVC
-- Found assembler: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.33.31629/bin/Hostx64/x64/ml64.exe
-- Looking for pthread.h
-- Looking for pthread.h - not found
-- Found Threads: TRUE
-- [cryptopp] Generating cmake package config files
-- [cryptopp] Generating pkgconfig files
-- [cryptopp] Platform: x86_64
-- [cryptopp] Compiler definitions:  CRYPTOPP_DATA_DIR="C:/Users/Admin/Source/Repos/cryptopp-cmake/build/_deps/cryptopp";_WIN32_WINNT=0x0A00
-- [cryptopp] Compiler options: /DWIN32 /D_WINDOWS /W3 /GR /EHsc  /FIwinapifamily.h;/GR;/EHsc
-- [cryptopp] Build type:
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Users/Admin/Source/Repos/cryptopp-cmake/build

C:\Users\Admin\Source\Repos\cryptopp-cmake\build>cmake --build .
MSBuild version 17.3.0+f67e3d35e for .NET Framework
  Checking Build System
  Building Custom Rule C:/Users/Admin/Source/Repos/cryptopp-cmake/cryptopp/CMakeLists.txt
  Assembling C:\Users\Admin\Source\Repos\cryptopp-cmake\build\_deps\cryptopp\rdrand.asm...
C:\Users\Admin\Source\Repos\cryptopp-cmake\build\_deps\cryptopp\rdrand.asm(1): fatal error A1000: cannot open file : cr
yptopp.dir\Debug\/__/_deps/cryptopp/rdrand.asm.obj [C:\Users\Admin\Source\Repos\cryptopp-cmake\build\cryptopp\cryptopp.
vcxproj]
C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\BuildCustomizations\masm.targets(70,5
): error MSB3721: Der Befehl "ml64.exe /c /nologo /Zi /Fo"cryptopp.dir\Debug\/__/_deps/cryptopp/rdrand.asm.obj" /D"WIN3
2" /D"_WINDOWS" /D"CMAKE_INTDIR="Debug"" /D"_M_X64" /I "C:\Users\Admin\Source\Repos\cryptopp-cmake\build\_deps\cryptopp
" /I "C:\Users\Admin\Source\Repos\cryptopp-cmake\build\_deps" /W3 /errorReport:prompt  /Ta"C:\Users\Admin\Source\Repos\
cryptopp-cmake\build\_deps\cryptopp\rdrand.asm"" wurde mit Code 1 beendet. [C:\Users\Admin\Source\Repos\cryptopp-cmake\
build\cryptopp\cryptopp.vcxproj]

I investigated some more on this error and found this error report by @piponazo: https://gitlab.kitware.com/cmake/cmake/-/issues/21462. The problem occurs because CMake generates a custom object output path for rdrand.asm (but not for any of the other .asm files), possibly because there also exists a rdrand.cpp with the same basename. It's visible in the generated cryptopp.vcxproj:

    <MASM Include="C:\Users\Admin\Source\Repos\cryptopp-cmake\build\_deps\cryptopp\rdrand.asm">
      <ObjectFileName>$(IntDir)/__/_deps/cryptopp/rdrand.asm.obj</ObjectFileName>
      <PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">%(PreprocessorDefinitions);_M_X64</PreprocessorDefinitions>
      <PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|x64'">%(PreprocessorDefinitions);_M_X64</PreprocessorDefinitions>
      <PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|x64'">%(PreprocessorDefinitions);_M_X64</PreprocessorDefinitions>
      <PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|x64'">%(PreprocessorDefinitions);_M_X64</PreprocessorDefinitions>
    </MASM>
    <MASM Include="C:\Users\Admin\Source\Repos\cryptopp-cmake\build\_deps\cryptopp\rdseed.asm">
      <PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">%(PreprocessorDefinitions);_M_X64</PreprocessorDefinitions>
      <PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|x64'">%(PreprocessorDefinitions);_M_X64</PreprocessorDefinitions>
      <PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|x64'">%(PreprocessorDefinitions);_M_X64</PreprocessorDefinitions>
      <PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|x64'">%(PreprocessorDefinitions);_M_X64</PreprocessorDefinitions>
    </MASM>
    <MASM Include="C:\Users\Admin\Source\Repos\cryptopp-cmake\build\_deps\cryptopp\x64dll.asm">
      <PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">%(PreprocessorDefinitions);_M_X64</PreprocessorDefinitions>
      <PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|x64'">%(PreprocessorDefinitions);_M_X64</PreprocessorDefinitions>
      <PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|x64'">%(PreprocessorDefinitions);_M_X64</PreprocessorDefinitions>
      <PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|x64'">%(PreprocessorDefinitions);_M_X64</PreprocessorDefinitions>
    </MASM>
    <MASM Include="C:\Users\Admin\Source\Repos\cryptopp-cmake\build\_deps\cryptopp\x64masm.asm">
      <PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">%(PreprocessorDefinitions);_M_X64</PreprocessorDefinitions>
      <PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|x64'">%(PreprocessorDefinitions);_M_X64</PreprocessorDefinitions>
      <PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|x64'">%(PreprocessorDefinitions);_M_X64</PreprocessorDefinitions>
      <PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|x64'">%(PreprocessorDefinitions);_M_X64</PreprocessorDefinitions>
    </MASM>

The relative path $(IntDir)/__/_deps/cryptopp/ does not exist and the ml64 build invocation fails.

According to @piponazo, the problem only occurs for MSBuild but not for Ninja. I'll see if we can override the object target path or rename the asm file to also make it work for MSBuild.