noloader / cryptopp-cmake

CMake files for Crypto++ project
BSD 3-Clause "New" or "Revised" License
92 stars 67 forks source link

Another fix to "winapifamily.h not found problem" #39

Closed LonghronShen closed 2 years ago

LonghronShen commented 5 years ago

The above solution doesn't work for me... But I found another solution: According to the answer here: https://stackoverflow.com/questions/40577415/detect-availablility-of-sdkddkver-h-and-winapifamily-h-from-developer-comman The CMakeList.txt can be modified like this.

noloader commented 5 years ago

I don't believe CMake honors things like %PATH% and other variables like %WINDOWSPHONEKITDIR % in a Developer Command Prompt. Or at least my testing did not confirm it.

If the changes are working for you it is probably a side effect of failing to honor them as expected.

LonghronShen commented 5 years ago

You're right... The syntax should be changed to $ENV{VAR} to get system environment. Let me have a try.

LonghronShen commented 5 years ago

The new fix has been done. It works as expected.

abdes commented 2 years ago

Please check the new implementation which should work in all environments:

if(MSVC)
  set(CRYPTOPP_MSVC_COMPILE_OPTIONS)

  # TODO: what about ICC and LLVM on Windows?

  if(CMAKE_SYSTEM_VERSION MATCHES "10\\.0.*")
    # https://docs.microsoft.com/en-us/cpp/porting/modifying-winver-and-win32-winnt
    list(APPEND CRYPTOPP_COMPILE_DEFINITIONS "_WIN32_WINNT=0x0A00")
  endif()
  # winapifamily.h is missing on AppVeyor machines
  include(CheckIncludeFileCXX)
  check_include_file_cxx("winapifamily.h" HAVE_WINAPIFAMILY_H)
  if(HAVE_WINAPIFAMILY_H)
    list(APPEND CRYPTOPP_MSVC_COMPILE_OPTIONS "/FIwinapifamily.h")
  endif()
endif()