Using CMAKE with visual studio buildtools 2017 ; unable to access UWP libs - c++

I'm trying to to use CMAKE with Visual Studio Buildtools 2017; and no matter what combination of flags or otherwise I am unable to get a working compilation. (I tried buildtools 2015 as well) I'm unable to access UWP libs, specifically platform.winmd
I always end with
fatal error C1107: could not find assembly 'platform.winmd': please specify the assembly search path using /AI or by setting the LIBPATH environment variable [C:\Users\ehiller\Dev\src\github.com\erichiller\uwp-js-test\build\winsearch.vcxproj]
My CMAKELISTS.txt looks like:
cmake_minimum_required(VERSION 3.7)
set(lib "winsearch")
file(GLOB SOURCE_FILES "src/module/winSearch/*.cpp" "src/module/winSearch/*.h")
add_library( ${lib} SHARED ${SOURCE_FILES})
set( MSVS15_COMPILE_FLAGS "/ZW" )
SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${MSVS15_COMPILE_FLAGS}" )
set_target_properties(${lib} PROPERTIES PREFIX "" SUFFIX ".node")
target_include_directories(${lib} PRIVATE ${CMAKE_JS_INC})
target_link_libraries(${lib} ${CMAKE_JS_LIB})
And I have removed all the source except for a blank function and a call to include #include <collection.h>
CMAKE itself is being called like:
cmake.exe "C:\Users\ehiller\Dev\src\github.com\erichiller\uwp-js-test" --no-warn-unused-cli -G"Visual Studio 15 2017 Win64" -DCMAKE_JS_VERSION="3.4.0" -DCMAKE_BUILD_TYPE="Release" -DCMAKE_RUNTIME_OUTPUT_DIRECTORY="C:\Users\ehiller\Dev\src\github.com\erichiller\uwp-js-test\build" -DCMAKE_JS_INC="C:\Users\ehiller\.cmake-js\electron-x64\v1.4.5\src;C:\Users\ehiller\.cmake-js\electron-x64\v1.4.5\deps\v8\include;C:\Users\ehiller\.cmake-js\electron-x64\v1.4.5\deps\uv\include;C:\Users\ehiller\Dev\src\github.com\erichiller\uwp-js-test\node_modules\nan" -DNODE_RUNTIME="electron" -DNODE_RUNTIMEVERSION="1.4.5" -DNODE_ARCH="x64" -DCMAKE_JS_LIB="C:\Users\ehiller\.cmake-js\electron-x64\v1.4.5\x64\node.lib"
The full output upon execution is:
info TOOL Using Visual Studio 15 2017 Win64 generator, as specified from commandline.
info CMD CLEAN
info RUN C:\Users\ehiller\AppData\Local\omega\system\cmake\bin\cmake.exe -E remove_directory "C:\Users\ehiller\Dev\src\github.com\erichiller\uwp-js-test\build"
> uwp-js-test#0.0.1 compile C:\Users\ehiller\Dev\src\github.com\erichiller\uwp-js-test
> cmake-js build -c "C:\Users\ehiller\AppData\Local\omega\system\cmake\bin\cmake.exe" -G "Visual Studio 15 2017 Win64"
info TOOL Using Visual Studio 15 2017 Win64 generator, as specified from commandline.
info CMD CONFIGURE
info RUN C:\Users\ehiller\AppData\Local\omega\system\cmake\bin\cmake.exe "C:\Users\ehiller\Dev\src\github.com\erichiller\uwp-js-test" --no-warn-unused-cli -G"Visual Studio 15 2017 Win64" -DCMAKE_JS_VERSION="3.4.0" -DCMAKE_BUILD_TYPE="Release" -DCMAKE_RUNTIME_OUTPUT_DIRECTORY="C:\Users\ehiller\Dev\src\github.com\erichiller\uwp-js-test\build" -DCMAKE_JS_INC="C:\Users\ehiller\.cmake-js\electron-x64\v1.4.5\src;C:\Users\ehiller\.cmake-js\electron-x64\v1.4.5\deps\v8\include;C:\Users\ehiller\.cmake-js\electron-x64\v1.4.5\deps\uv\include;C:\Users\ehiller\Dev\src\github.com\erichiller\uwp-js-test\node_modules\nan" -DNODE_RUNTIME="electron" -DNODE_RUNTIMEVERSION="1.4.5" -DNODE_ARCH="x64" -DCMAKE_JS_LIB="C:\Users\ehiller\.cmake-js\electron-x64\v1.4.5\x64\node.lib"
Not searching for unused variables given on the command line.
-- The C compiler identification is MSVC 19.10.24930.0
-- The CXX compiler identification is MSVC 19.10.24930.0
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/VC/Tools/MSVC/14.10.24930/bin/HostX86/x64/cl.exe
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/VC/Tools/MSVC/14.10.24930/bin/HostX86/x64/cl.exe -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/VC/Tools/MSVC/14.10.24930/bin/HostX86/x64/cl.exe
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/VC/Tools/MSVC/14.10.24930/bin/HostX86/x64/cl.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Users/ehiller/Dev/src/github.com/erichiller/uwp-js-test/build
info CMD BUILD
info RUN C:\Users\ehiller\AppData\Local\omega\system\cmake\bin\cmake.exe --build "C:\Users\ehiller\Dev\src\github.com\erichiller\uwp-js-test\build" --config Release
Microsoft (R) Build Engine version 15.1.545.13942
Copyright (C) Microsoft Corporation. All rights reserved.
Build started 2/18/2017 9:27:58 PM.
Project "C:\Users\ehiller\Dev\src\github.com\erichiller\uwp-js-test\build\ALL_BUILD.vcxproj" on node 1 (default targets).
Project "C:\Users\ehiller\Dev\src\github.com\erichiller\uwp-js-test\build\ALL_BUILD.vcxproj" (1) is building "C:\Users\ehiller\Dev\src\github.com\erichiller\uwp-js-te st\build\ZERO_CHECK.vcxproj" (2) on node 1 (default targets).
PrepareForBuild:
Creating directory "x64\Release\ZERO_CHECK\".
Creating directory "x64\Release\ZERO_CHECK\ZERO_CHECK.tlog\".
InitializeBuildStatus:
Creating "x64\Release\ZERO_CHECK\ZERO_CHECK.tlog\unsuccessfulbuild" because "AlwaysCreate" was specified.
CustomBuild:
Checking Build System
CMake does not need to re-run because C:/Users/ehiller/Dev/src/github.com/erichiller/uwp-js-test/build/CMakeFiles/generate.stamp is up-to-date.
FinalizeBuildStatus:
Deleting file "x64\Release\ZERO_CHECK\ZERO_CHECK.tlog\unsuccessfulbuild".
Touching "x64\Release\ZERO_CHECK\ZERO_CHECK.tlog\ZERO_CHECK.lastbuildstate".
Done Building Project "C:\Users\ehiller\Dev\src\github.com\erichiller\uwp-js-test\build\ZERO_CHECK.vcxproj" (default targets).
Project "C:\Users\ehiller\Dev\src\github.com\erichiller\uwp-js-test\build\ALL_BUILD.vcxproj" (1) is building "C:\Users\ehiller\Dev\src\github.com\erichiller\uwp-js-te st\build\winsearch.vcxproj" (3) on node 1 (default targets).
PrepareForBuild:
Creating directory "winsearch.dir\Release\".
Creating directory "C:\Users\ehiller\Dev\src\github.com\erichiller\uwp-js-test\build\Release\".
Creating directory "winsearch.dir\Release\winsearch.tlog\".
InitializeBuildStatus:
Creating "winsearch.dir\Release\winsearch.tlog\unsuccessfulbuild" because "AlwaysCreate" was specified.
CustomBuild:
Building Custom Rule C:/Users/ehiller/Dev/src/github.com/erichiller/uwp-js-test/CMakeLists.txt
CMake does not need to re-run because C:/Users/ehiller/Dev/src/github.com/erichiller/uwp-js-test/build/CMakeFiles/generate.stamp is up-to-date.
ClCompile:
C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.10.24930\bin\HostX86\x64\CL.exe /c /I"C:\Users\ehiller\.cmake-js\electron-x64\v1.4.5
\src" /I"C:\Users\ehiller\.cmake-js\electron-x64\v1.4.5\deps\v8\include" /I"C:\Users\ehiller\.cmake-js\electron-x64\v1.4.5\deps\uv\include" /I"C:\Users\ehiller\Dev\
src\github.com\erichiller\uwp-js-test\node_modules\nan" /ZW /nologo /W3 /WX- /diagnostics:classic /O2 /Ob2 /D WIN32 /D _WINDOWS /D NDEBUG /D "CMAKE_INTDIR=\"Release
\"" /D winsearch_EXPORTS /D _WINDLL /D _MBCS /Gm- /EHsc /MD /GS /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /GR /Fo"winsearch.dir\Release\\" /Fd"winsearch.dir\R
elease\vc141.pdb" /Gd /TP /errorReport:queue "C:\Users\ehiller\Dev\src\github.com\erichiller\uwp-js-test\src\module\winSearch\winSearch.cpp"
winSearch.cpp
C:\Users\ehiller\Dev\src\github.com\erichiller\uwp-js-test\src\module\winSearch\winSearch.cpp : fatal error C1107: could not find assembly 'platform.winmd': please sp ecify the assembly search path using /AI or by setting the LIBPATH environment variable [C:\Users\ehiller\Dev\src\github.com\erichiller\uwp-js-test\build\winsearch.vc xproj]
Done Building Project "C:\Users\ehiller\Dev\src\github.com\erichiller\uwp-js-test\build\winsearch.vcxproj" (default targets) -- FAILED.
Done Building Project "C:\Users\ehiller\Dev\src\github.com\erichiller\uwp-js-test\build\ALL_BUILD.vcxproj" (default targets) -- FAILED.
Build FAILED.
"C:\Users\ehiller\Dev\src\github.com\erichiller\uwp-js-test\build\ALL_BUILD.vcxproj" (default target) (1) ->
"C:\Users\ehiller\Dev\src\github.com\erichiller\uwp-js-test\build\winsearch.vcxproj" (default target) (3) ->
(ClCompile target) ->
C:\Users\ehiller\Dev\src\github.com\erichiller\uwp-js-test\src\module\winSearch\winSearch.cpp : fatal error C1107: could not find assembly 'platform.winmd': please
specify the assembly search path using /AI or by setting the LIBPATH environment variable [C:\Users\ehiller\Dev\src\github.com\erichiller\uwp-js-test\build\winsearch. vcxproj]
0 Warning(s)
1 Error(s)
Time Elapsed 00:00:00.49
I have
C:\Program Files (x86)\Windows Kits\10\UnionMetadata\Windows.winmd
C:/Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/VC/Tools/MSVC/14.10.24930/lib/x86/store/references/platform.winmd
And I tried including them as libraries with
target_link_libraries( ${lib} "C:/Program Files (x86)/Windows Kits/10/UnionMetadata/Windows.winmd" )
TARGET_LINK_LIBRARIES(${lib} "C:/Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/VC/Tools/MSVC/14.10.24930/lib/x86/store/references/platform.winmd")
But none of that does anything either.
Nor does setting the CMAKE_SYSTEM_NAME
set( CMAKE_SYSTEM_NAME WindowsStore )
or the CMAKE_SYSTEM_VERSION
set( CMAKE_SYSTEM_VERSION 10.0 )
I even tried setting the library to every directory I could find in the sdk.bat file:
set( sd "C:/Program Files (x86)/Windows Kits/10/" )
set( WindowsSDKVersion "10.0.14393.0" )
target_link_libraries( ${lib} "${sd}bin")
target_link_libraries( ${lib} "${sd}UnionMetadata")
target_link_libraries( ${lib} "${sd}References")
target_link_libraries( ${lib} "${sd}bin")
target_link_libraries( ${lib} "{sd}bin" )
target_link_libraries( ${lib} "${sd}UnionMetadata" )
target_link_libraries( ${lib} "${sd}References" )
target_link_libraries( ${lib} "${sd}lib/${WindowsSDKLibVersion}/um/${NODE_ARCH}" )
target_link_libraries( ${lib} "${sd}include/${WindowsSDKVersion}/shared/" )
target_link_libraries( ${lib} "${sd}include/${WindowsSDKVersion}/um/" )
target_link_libraries( ${lib} "${sd}include/${WindowsSDKVersion}/winrt/" )
target_link_libraries( ${lib} "${sd}References/CommonConfiguration/Neutral" )
But that wasn't it either.
So I am at the point now that I am sure I missing something obvious. So I am hoping somebody can help me out here! Thanks!
(by the way, the cmake-js is a frontend for cmake, it just passes the flags right along to cmake and should not affect the system, but just to make sure, I tried running cmake directly, with the same results)

According to Microsoft's documentation to specify metadata directories, you have to pass the compiler option -AI"directory-path" for the winmd libraries. For the case of Visual C++ 2017, try augmenting the C++ options in your CMakeLists.txt file like this:
# windows.winmd search path:
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -AI\"C:/Program Files (x86)/Windows Kits/10/UnionMetadata\"" )
# platform.winmd search path for MSVC 2017:
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -AI\"C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/Common7/IDE/VC/vcpackages\"" )
I have tested these two search paths only on Visual Studio 2017 and Windows 10. You will have to modify one or possibly both paths should you have different versions.

Related

VCPKG_ROOT not defined for CMake

I am trying to set up vcpkg with a CMake project. Since I intend to have multiple people with different platforms working on this project, I wanted to use an Environment Variable to set CMAKE_TOOLCHAIN_FILE instead of a command line argument as recommended here for cmake: https://vcpkg.readthedocs.io/en/latest/users/integration/
However, It appears that CMake is unable to find the VCPKG_ROOT environment variable. I made a small example separate from my project to see if the problem still exists and it does. Here is my CMakeLists.txt file:
cmake_minimum_required (VERSION 3.8)
#vcpkg init
if(DEFINED ENV{VCPKG_ROOT} AND NOT DEFINED CMAKE_TOOLCHAIN_FILE)
MESSAGE("vcpkg root found")
set(CMAKE_TOOLCHAIN_FILE "$ENV{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake"
CACHE STRING "")
else()
MESSAGE("vcpkg not found")
endif()
project ("CmakeVcpkgTestF")
add_executable (CmakeVcpkgTestF "CmakeVcpkgTestF.cpp" "CmakeVcpkgTestF.h")
And here is the associated output when buliding, note that "vcpkg not found is output" instead of "vcpkg root found"
1> CMake generation started for default configuration: 'x64-Debug (default)'.
1> Command line: "cmd.exe" /c "%SYSTEMROOT%\System32\chcp.com 65001 >NUL && "C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO\2019\COMMUNITY\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\CMAKE\CMake\bin\cmake.exe" -G "Ninja" -DCMAKE_BUILD_TYPE:STRING="Debug" -DCMAKE_INSTALL_PREFIX:PATH="F:\VisualStudio2019\CmakeVcpkgTestF\out\install\x64-Debug (default)" -DCMAKE_C_COMPILER:FILEPATH="C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.28.29333/bin/Hostx64/x64/cl.exe" -DCMAKE_CXX_COMPILER:FILEPATH="C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.28.29333/bin/Hostx64/x64/cl.exe" -DCMAKE_MAKE_PROGRAM="C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO\2019\COMMUNITY\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\CMAKE\Ninja\ninja.exe" "F:\VisualStudio2019\CmakeVcpkgTestF" 2>&1"
1> Working directory: F:\VisualStudio2019\CmakeVcpkgTestF\out\build\x64-Debug (default)
1> [CMake] vcpkg not found
1> [CMake] -- Configuring done
1> [CMake] -- Generating done
1> [CMake] -- Build files have been written to: F:/VisualStudio2019/CmakeVcpkgTestF/out/build/x64-Debug (default)
1> Extracted CMake variables.
1> Extracted source files and headers.
1> Extracted code model.
1> Extracted includes paths.
1> CMake generation finished.
So far all I have done install vcpkg (running the required bootstrap as well), is there something else I need to do to get this to work? Also it is worth noting that vcpkg is installed at the root of my drive(specifically F:/vcpkg/vcpkg), not at root of the code, but I don't imagine that is causing the problem.
Thanks in advance for any assistance.
Based on your output, this is the second time your code has run. Your if condition asks whether CMAKE_TOOLCHAIN_FILE is defined at all, but it is! You defined it as a cache variable, which was then loaded into the global scope on the second run.
You probably want a test more like this:
set(vcpkg "$ENV{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake")
if(NOT CMAKE_TOOLCHAIN_FILE AND EXISTS "${vcpkg}")
set(CMAKE_TOOLCHAIN_FILE "${vcpkg}"
CACHE FILEPATH "CMake toolchain file")
message(STATUS "vcpkg toolchain found: ${CMAKE_TOOLCHAIN_FILE}")
endif()

Cmake - fatal error LNK1104: cannot open file 'libboost_date_time-vc142-mt-gd

I am trying to build my project on Windows. On Linux it works perfectly fine.
Here is my main CMakeLists.txt file:
cmake_minimum_required(VERSION 3.16)
project(Vibranium_Core)
set(CMAKE_CXX_STANDARD 17)
set(FLATBUFFERS_MAX_PARSING_DEPTH 16)
set(FLATBUFFERS_LOCATION "E:/vcpkg/packages/flatbuffers_x86-windows")
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O0")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O0")
endif()
if(EXISTS "${CMAKE_SOURCE_DIR}/.git")
execute_process(
COMMAND git rev-list --count HEAD
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE GIT_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE
)
execute_process(
COMMAND git rev-parse --abbrev-ref HEAD
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE GIT_BRANCH
OUTPUT_STRIP_TRAILING_WHITESPACE
)
execute_process(
COMMAND git log -1 --format=%h
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE GIT_COMMIT_HASH
OUTPUT_STRIP_TRAILING_WHITESPACE
)
execute_process(
COMMAND git --no-pager log -1 --format=%ai
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE GIT_RELEASED_ON
OUTPUT_STRIP_TRAILING_WHITESPACE
)
else(EXISTS "${CMAKE_SOURCE_DIR}/.git")
set(GIT_BRANCH "")
set(GIT_COMMIT_HASH "")
endif(EXISTS "${CMAKE_SOURCE_DIR}/.git")
message(STATUS "VibraniumCore current branch: ${GIT_BRANCH}")
message(STATUS "VibraniumCore Version: ${GIT_VERSION}")
message(STATUS "VibraniumCore commit hash: ${GIT_COMMIT_HASH}")
message(STATUS "Released on: ${GIT_RELEASED_ON}")
message(STATUS "Generating version.h")
configure_file(
${CMAKE_SOURCE_DIR}/cmake/version.h.in
${CMAKE_SOURCE_DIR}/Source/Common/Version.h
)
find_package(Boost 1.72.0)
find_package(Threads)
add_definitions(-DGIT_COMMIT_HASH="${GIT_COMMIT_HASH}")
add_definitions(-DGIT_BRANCH="${GIT_BRANCH}")
add_definitions(-DGIT_VERSION="${GIT_VERSION}")
add_definitions(-DGIT_RELEASED_ON="${GIT_RELEASED_ON}")
if(NOT Boost_FOUND)
message(FATAL_ERROR "Could not find boost!")
endif()
include_directories(${Boost_INCLUDE_DIR})
if("${CMAKE_SIZEOF_VOID_P}" EQUAL "8")
message(STATUS "Target is 64 bits")
if (WIN32)
set(WINXXBITS Win64)
endif(WIN32)
else("${CMAKE_SIZEOF_VOID_P}" EQUAL "8")
message(STATUS "Target is 32 bits")
if (WIN32)
set(WINXXBITS Win32)
endif(WIN32)
endif("${CMAKE_SIZEOF_VOID_P}" EQUAL "8")
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/")
find_package(MySQL REQUIRED)
if(WIN32)
find_package(Flatbuffers REQUIRED
PATHS ${FLATBUFFERS_LOCATION})
else()
find_package(Flatbuffers REQUIRED
PATHS /usr/local/flatbuffers)
endif()
include_directories(${MYSQL_INCLUDE_DIR})
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/Source/Common)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/Source/Core/WorldServer)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/Source/Core/AuthServer)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/Source/ClientEmulator)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/Source/Game)
add_subdirectory(Tests)
set_target_properties(VibraniumCoreTests PROPERTIES EXCLUDE_FROM_ALL TRUE)
set_target_properties(gtest PROPERTIES EXCLUDE_FROM_ALL TRUE)
set_target_properties(gmock PROPERTIES EXCLUDE_FROM_ALL TRUE)
set_target_properties(gtest_main PROPERTIES EXCLUDE_FROM_ALL TRUE)
set_target_properties(gmock_main PROPERTIES EXCLUDE_FROM_ALL TRUE)
set_target_properties(
Common WorldServer AuthServer ClientEmulator Game
PROPERTIES
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin/lib"
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin/lib"
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin"
)
Here is my Common CMakeLists.txt:
file(GLOB flatBufferFiles_SRC
"Server/Packets/*/*.h"
"Server/Packets/*/*.cc"
)
add_library(
Common
SHARED
Config.cpp
Config.h
Logger.cpp
Logger.h
Database/MySQLConnection.h
Database/MySQLConnection.cpp
Database/MySQLTable.h
Database/MySQLTable.cpp
Banner.cpp
Banner.h
Database/MySQLTableBase.cpp
Database/MySQLTableBase.h
Memory/Memory.cpp
Memory/Memory.h
Server/Server.cpp
Server/Server.h
Server/Client.cpp
Server/Client.h
Server/Client.cpp
Server/Client.h
DataSchemas/Account.h
DataSchemas/AccountRole.h
${flatBufferFiles_SRC}
Helpers/Timer.h
Crypto/sha512.h
Server/Packet.cpp Server/Packet.h Server/Protocol/ServerOpcode.h Server/Protocol/ClientOpcode.h Server/Protocol/Opcodes.cpp Server/Protocol/Opcodes.h Server/WorldSession.cpp Server/WorldSession.h Server/AuthSession.cpp Server/AuthSession.h)
target_include_directories(Common PUBLIC ${FULL_PATH_TO_MYSQL_CONNECTOR_CPP_DIR}/include ${FLATBUFFERS_LOCATION}/include)
target_include_directories(Common PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${MYSQL_LIBRARY} ${CMAKE_CURRENT_SOURCE_DIR}/Server/Packets)
target_link_libraries(Common PUBLIC ${MYSQL_CONNECTOR_LIBRARY} ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES})
When I run cmake I get the following:
-- The C compiler identification is MSVC 19.24.28315.0
-- The CXX compiler identification is MSVC 19.24.28315.0
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.24.28314/bin/Hostx64/x64/cl.exe
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.24.28314/bin/Hostx64/x64/cl.exe - works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.24.28314/bin/Hostx64/x64/cl.exe
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.24.28314/bin/Hostx64/x64/cl.exe - works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- VibraniumCore current branch: windows
-- VibraniumCore Version: 161
-- VibraniumCore commit hash: d8d564d
-- Released on: 2020-10-26 11:26:24 +0200
-- Generating version.h
-- Found Boost: C:/local/boost_1_72_0 (found suitable version "1.72.0", minimum required is "1.72.0")
-- Looking for pthread.h
-- Looking for pthread.h - not found
-- Found Threads: TRUE
-- Target is 64 bits
-- New WorldServer Config file in will be installed in: E:/Vibranium-Core/cmake-build-debug/bin/configs
-- New AuthServer Config file in will be installed in: E:/Vibranium-Core/cmake-build-debug/bin/configs
-- Found PythonInterp: C:/Program Files (x86)/Python38-32/python.exe (found version "3.8.5")
-- Configuring done
-- Generating done
-- Build files have been written to: E:/Vibranium-Core/cmake-build-debug
[Finished]
So boost is found. However when I try to build I get the following error:
====================[ Build | AuthServer | Debug ]==============================
"C:\Program Files\JetBrains\CLion 2020.1.3\bin\cmake\win\bin\cmake.exe" --build E:\Vibranium-Core\cmake-build-debug --target AuthServer
[ 4%] Linking CXX shared library ..\..\bin\Common.dll
LINK Pass 1: command "C:\PROGRA~2\MICROS~1\2019\COMMUN~1\VC\Tools\MSVC\1424~1.283\bin\Hostx64\x64\link.exe /nologo #CMakeFiles\Common.dir\objects1.rsp /out:..\..\bin\Common.dll /implib:..\..\bin\lib\Common.lib /pdb:E:\Vibranium-Core\cmake-build-debug\bin\Common.pdb /dll /version:0.0 /machine:x64 /debug /INCREMENTAL C:\Program Files\MySQL\Connector C++ 8.0\lib64\vs14\mysqlcppconn8.lib kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib /MANIFEST /MANIFESTFILE:CMakeFiles\Common.dir/intermediate.manifest CMakeFiles\Common.dir/manifest.res" failed (exit code 1104) with the following output:
LINK : fatal error LNK1104: cannot open file 'libboost_date_time-vc142-mt-gd-x64-1_72.lib'
NMAKE : fatal error U1077: '"C:\Program Files\JetBrains\CLion 2020.1.3\bin\cmake\win\bin\cmake.exe"' : return code '0xffffffff'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.24.28314\bin\HostX64\x64\nmake.exe"' : return code '0x2'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.24.28314\bin\HostX64\x64\nmake.exe"' : return code '0x2'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.24.28314\bin\HostX64\x64\nmake.exe"' : return code '0x2'
Stop.
I checked and I have this file libboost_date_time-vc142-mt-gd-x64-1_72.lib it is located in C:\local\boost_1_72_0\lib64-msvc-14.2
Also when I do :
message("BOOST LIBRARIES LOCATION: " ${Boost_LIBRARIES})
It comes up BOOST LIBRARIES LOCATION: so this variable on Windows ${Boost_LIBRARIES} is empty. Why is that and why it works on Linux but not on Windows ?
Most but not all Boost libraries are header only. Boost date_time is not therefore it needs to be added to your find_package command for Boost.
find_package(Boost 1.72.0 COMPONENTS date_time)
This will find the Boost DLLs on windows.
If you are interested in the static libraries you need to add
set(Boost_USE_STATIC_LIBS ON)
before your find_package_command.
After applying the changes to your CMakeLists.txt file clear the CMake cache, i.e. delete the CMakeCache.txt file in your build directory and rerun CMake.
If you are using Visual Studio, Have you tried using Tools / NuGet Package Manager to install boost_program_options-vc142? That worked for me.

Configure CMake in windows to use clang from command line to get modern OpenMP support

I have a small test project that uses OpenMP for parallelization. My target is to compile it so it produces .dll and .lib for libraries (because my real project links to external libraries distributed using these types), with support for OpenMP 4.5 or newer and do it from the command line so it can be done on a docker for testing and checking (the docker part is out of the scope of this question, it is just for reference on why I need it to work from the command line). I can compile this project with different compilers with which I am not happy:
MSVC: mkdir build-msvc, then cmake .. (from the newly created folder) and finally cmake --build . --config Release. This compiles fine but only supports OpenMP 2.0, therefore is not a good option for my real project.
Intel Parallel Studio: mkdir build-intel, then cmake .. -T "Intel C++ Compiler 19.0" (from the newly created folder) and finally cmake --build . --config Release. This supports OpenMP 5.0 but its licenses are pretty expensive for me.
MinGW x64 g++: mkdir build-g++, then cmake .. -G "MinGW Makefiles" (from the newly created folder) and finally cmake --build .. It supports OpenMP 4.5 but this compiler is not compatible wiht .lib (as far as I know) which I already mentioned is necessary for me.
I have tried without success to use clang:
CLANG from MSVC: mkdir build-clang-msvc, then cmake -G Ninja -DCMAKE_CXX_COMPILER=clang-cl .. (from the newly created folder), but it fails with the following error:
-- The CXX compiler identification is Clang 8.0.1 with MSVC-like command-line
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/Llvm/bin/clang-cl.exe
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/Llvm/bin/clang-cl.exe -- broken
CMake Error at C:/Program Files/CMake/share/cmake-3.15/Modules/CMakeTestCXXCompiler.cmake:53 (message):
The C++ compiler
"C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/Llvm/bin/clang-cl.exe"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: C:/Users/[USER NAME]/source/repos/test_openmp/build-clang-msvc/CMakeFiles/CMakeTmp
Run Build Command(s):C:/PROGRA~2/MICROS~1/2019/COMMUN~1/Common7/IDE/COMMON~1/MICROS~1/CMake/Ninja/ninja.exe cmTC_bd131 && [1/2] Building CXX object CMakeFiles\cmTC_bd131.dir\testCXXCompiler.cxx.obj
[2/2] Linking CXX executable cmTC_bd131.exe
FAILED: cmTC_bd131.exe
cmd.exe /C "cd . && "C:\Program Files\CMake\bin\cmake.exe" -E vs_link_exe --intdir=CMakeFiles\cmTC_bd131.dir --rc=rc --mt=CMAKE_MT-NOTFOUND --manifests -- C:\PROGRA~1\MINGW-~1\X86_64~1.0-P\mingw64\bin\ld.exe /nologo CMakeFiles\cmTC_bd131.dir\testCXXCompiler.cxx.obj /out:cmTC_bd131.exe /implib:cmTC_bd131.lib /pdb:cmTC_bd131.pdb /version:0.0 /machine:X86 /debug /INCREMENTAL /subsystem:console kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib && cd ."
RC Pass 1: command "rc /fo CMakeFiles\cmTC_bd131.dir/manifest.res CMakeFiles\cmTC_bd131.dir/manifest.rc" failed (exit code 0) with the following output:
The system cannot find the file specified
ninja: build stopped: subcommand failed.
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:2 (project)
-- Configuring incomplete, errors occurred!
See also "C:/Users/[USER NAME]/source/repos/test_openmp/build-clang-msvc/CMakeFiles/CMakeOutput.log".
See also "C:/Users/[USER NAME]/source/repos/test_openmp/build-clang-msvc/CMakeFiles/CMakeError.log".
Clang and Ninja apart from MSVC: mkdir build-clang-ninja, then cmake -G Ninja -DCMAKE_CXX_COMPILER=clang-cl .. (from the newly created folder and changing the PATH environmental variable so the non-msvc are found first), but it fails with the following error:
-- The CXX compiler identification is Clang 9.0.0 with MSVC-like command-line
-- Check for working CXX compiler: C:/Program Files/LLVM/bin/clang-cl.exe
-- Check for working CXX compiler: C:/Program Files/LLVM/bin/clang-cl.exe -- broken
CMake Error at C:/Program Files/CMake/share/cmake-3.15/Modules/CMakeTestCXXCompiler.cmake:53 (message):
The C++ compiler
"C:/Program Files/LLVM/bin/clang-cl.exe"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: C:/Users/[USER NAME]/source/repos/test_openmp/buid-clang-ninja/CMakeFiles/CMakeTmp
Run Build Command(s):C:/Ninja/ninja.exe cmTC_50b73 && [1/2] Building CXX object CMakeFiles\cmTC_50b73.dir\testCXXCompiler.cxx.obj
[2/2] Linking CXX executable cmTC_50b73.exe
FAILED: cmTC_50b73.exe
cmd.exe /C "cd . && "C:\Program Files\CMake\bin\cmake.exe" -E vs_link_exe --intdir=CMakeFiles\cmTC_50b73.dir --rc=rc --mt=CMAKE_MT-NOTFOUND --manifests -- CMAKE_LINKER-NOTFOUND /nologo CMakeFiles\cmTC_50b73.dir\testCXXCompiler.cxx.obj /out:cmTC_50b73.exe /implib:cmTC_50b73.lib /pdb:cmTC_50b73.pdb /version:0.0 /machine:x64 /debug /INCREMENTAL /subsystem:console kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib && cd ."
RC Pass 1: command "rc /fo CMakeFiles\cmTC_50b73.dir/manifest.res CMakeFiles\cmTC_50b73.dir/manifest.rc" failed (exit code 0) with the following output:
The system cannot find the file specified
ninja: build stopped: subcommand failed.
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:2 (project)
-- Configuring incomplete, errors occurred!
See also "C:/Users/[USER NAME]/source/repos/test_openmp/buid-clang-ninja/CMakeFiles/CMakeOutput.log".
See also "C:/Users/[USER NAME]/source/repos/test_openmp/buid-clang-ninja/CMakeFiles/CMakeError.log".
Any ideas on how to proceed with the clang? I think it is my best option for what I want to achieve (compile my test program with support for OpenMP 4.5 or newer and producing .lib and .dll).
Related posts/webpages that I have checked but have been non-useful to solve this:
Building c++ project on Windows with CMake, Clang and Ninja
Building with CMake, Ninja and Clang on Windows
Ways to Compile with Clang on Windows, specifically setting the linker: -DCMAKE_LINKER="C:/Program Files/LLVM/bin/lld-link.exe"
CMake building for Windows (clang-cl) using Ninja Generator
Clang-cl user manual
I was able to duplicate this error for the Clang+MSVC case. Because we are attempting to use the Visual-Studio-tailored compiler from outside Visual Studio (i.e. the command line), it is necessary to initialize the VS build environment in our command line before using the compiler. The VCVarsXX.bat files accomplish this; they are part of the VS Command Prompt tools. So by picking your architecture (x86, x64, etc) and running the script, this should allow CMake to build the simple test program with clang-cl and proceed. Here is where it is located for VS 2019:
>"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvarsall.bat" x86
>cmake -G Ninja -DCMAKE_CXX_COMPILER=clang-cl ..
-- The CXX compiler identification is Clang 8.0.1
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/Llvm/bin/clang-cl.exe
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/Llvm/bin/clang-cl.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
...
To expand on the OpenMP issue, I personally found using find_package(OpenMP REQUIRED) to be pretty fruitless. As you mentioned, I also received this CMake error:
Could NOT find OpenMP_CXX (missing: OpenMP_CXX_FLAGS OpenMP_CXX_LIB_NAMES)
There are a few suggestions on this site (for example here and here) claiming that populating all of the variables manually allows FindOpenMP.cmake to successfully find the libraries. I tried this with your example CMake file, with some success:
cmake_minimum_required (VERSION 2.8)
project(test_openmp LANGUAGES CXX)
set(OpenMP_CXX "${CMAKE_CXX_COMPILER}")
set(OpenMP_CXX_FLAGS "-Xclang -fopenmp")
set(OpenMP_CXX_LIB_NAMES "libomp" "libiomp5")
set(OpenMP_libomp_LIBRARY libomp)
set(OpenMP_libiomp5_LIBRARY libiomp5)
#OPENMP
find_package(OpenMP REQUIRED)
if(OPENMP_FOUND)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}")
endif()
# Library
add_library(example_lib SHARED example_lib.h example_lib.cpp)
target_link_libraries(example_lib PUBLIC ${OpenMP_CXX_LIBRARIES})
target_compile_definitions(example_lib PRIVATE EXEMPLE_LIB_EXPORT)
# Executable
add_executable(test_openmp test_openmp.cpp)
target_link_libraries(test_openmp example_lib)
This succeeded in "finding" the libraries on the second CMake configuration attempt (the first always yielded the same Could NOT find OpenMP_CXX error as before):
>cmake -G Ninja -DCMAKE_CXX_COMPILER=clang-cl ..
-- Found OpenMP_CXX: -Xclang -fopenmp (found version "3.1")
-- Found OpenMP: TRUE (found version "3.1")
-- Configuring done
-- Generating done
However, this failed to build the executable, as none of the CMake OpenMP variables (particularly OpenMP_CXX_LIBRARIES) actually point to the library location. The shortcomings of CMake's FindOpenMP.cmake have been raised on the CMake issue site here, and there appear to be relevant limitations on the LLVM/Clang end as well.
Regardless, the cleanest way I was able to get the example working was to ditch find_package() altogether. The following allowed me to successfully generate the buildsystem, and compile and run the executable:
cmake_minimum_required (VERSION 2.8)
project(test_openmp LANGUAGES CXX)
set(OpenMP_LIBRARY_DIR "C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/Llvm/lib")
set(OpenMP_CXX_FLAGS "-Xclang -fopenmp")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
# Tell CMake where to find the OpenMP libraries.
link_directories(${OpenMP_LIBRARY_DIR})
# Library
add_library(example_lib SHARED example_lib.h example_lib.cpp)
# Link in the OpenMP libraries.
target_link_libraries(example_lib PUBLIC libomp libiomp5md)
target_compile_definitions(example_lib PRIVATE EXEMPLE_LIB_EXPORT)
# Executable
add_executable(test_openmp test_openmp.cpp)
target_link_libraries(test_openmp example_lib)

C++ - cmake cannot find boost libraries

For a project, I have to use cmake in combination with boost to generate a C++ build (avro). I have installed the following programs:
cmake v3.4.3
boost v1.55.0
But when executing the command with the following statements in the .bat file (this batch file got provided by a 3th party provider),
set BOOST_ROOT=D:\software\boost_1_55_0\
set BOOST_INCLUDEDIR=D:\software\boost_1_55_0\boost
set BOOST_LIBRARYDIR=D:\software\boost_1_55_0\lib32-msvc-12.0
set PATH=%MSVS_HOME%\VC;%BOOST_LIBRARYDIR%;%BOOST_ROOT%;%BOOST_INCLUDEDIR%;%PATH%
call vcvarsall.bat
cmake .. -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=Debug
(remark: MSVS_HOME is the directory where Visual Studio got installed to and the other paths are set by my own.)
cmake throws up with errors, as shown here below
CMake Error at D:/software/cmake_3.4.3/share/cmake-3.4/Modules/FindBoost.cmake:1247 (message):
Unable to find the requested Boost libraries.
Boost version: 1.55.0
Boost include path: D:/software/boost_1_55_0
Could not find the following Boost libraries:
boost_filesystem
boost_system
boost_program_options
No Boost libraries were found. You may need to set BOOST_LIBRARYDIR to the
directory containing Boost libraries or BOOST_ROOT to the location of Boost.
Call Stack (most recent call first):
CMakeLists.txt:54 (find_package)
-- Configuring incomplete, errors occurred!
See also "D:/kaa/kaaBuild/avro-src-1.7.5/lang/c++/build.win/CMakeFiles/CMakeOutput.log".
It however surprises me because in the boost directory, you can find the required libraries. Here below are PS commands that I have used to find the required Boost libraries.
PS D:\software\boost_1_55_0\lib32-msvc-12.0> Get-ChildItem boost_file* -name
boost_filesystem-vc120-1_55.dll
boost_filesystem-vc120-1_55.lib
boost_filesystem-vc120-gd-1_55.dll
boost_filesystem-vc120-gd-1_55.lib
boost_filesystem-vc120-mt-1_55.dll
boost_filesystem-vc120-mt-1_55.lib
boost_filesystem-vc120-mt-gd-1_55.dll
boost_filesystem-vc120-mt-gd-1_55.lib
PS D:\software\boost_1_55_0\lib32-msvc-12.0> Get-ChildItem boost_system* -name
boost_system-vc120-1_55.dll
boost_system-vc120-1_55.lib
boost_system-vc120-gd-1_55.dll
boost_system-vc120-gd-1_55.lib
boost_system-vc120-mt-1_55.dll
boost_system-vc120-mt-1_55.lib
boost_system-vc120-mt-gd-1_55.dll
boost_system-vc120-mt-gd-1_55.lib
PS D:\software\boost_1_55_0\lib32-msvc-12.0> Get-ChildItem boost_program_opt* -name
boost_program_options-vc120-1_55.dll
boost_program_options-vc120-1_55.lib
boost_program_options-vc120-gd-1_55.dll
boost_program_options-vc120-gd-1_55.lib
boost_program_options-vc120-mt-1_55.dll
boost_program_options-vc120-mt-1_55.lib
boost_program_options-vc120-mt-gd-1_55.dll
As you can see, the required file is available in the right location.
Question :
I am not familiar with cmake. Could the problem be at the cmake list (here below) or is the problem somewhere else ? I already have looked into the following questions:
c++ - cmake cannot find boost libraries
The answer goes about a configuration problem. But since I have barely experience with cmake, I am not sure if the configuration is correct. I didn't have configured it. These files got provided to me by a 3th party provider...
C++ - CMAKE cannot find boost
There is no answer, but in the comment, it mentions about the variables. I have set it correctly here (I think ...)
Cmake doesn't find Boost
The answer tells to add those two lines before the FIND_PACKAGE(Boost) but my cmakelists.txt (here below) doesn't contain it.
C++ - CMake is not able to find boost libraries
The answers were vague, I don't know which one would be useful. There is an answer that mentions a snippet which can be added to the cmakelists.txt. I'm not sure if I should do that. (As said, the files got provided by a 3th party provider)
I have also checked the following answers outside StackOverflow:
this, which tells about the environment variables, something what I already have
this, it mentions about a version of libdev boost. I do think that I have the latest version. (see above, I have Boost 1.55)
this, that mentions to remove the cmake file. However, it works for orocos, something that I don't use. I don't think that this wouldn't solve my problem either. But I tried it anyways, and no, didn't helped.
So, what can I do to solve this problem ? Did I have overlooked on something ? Missed something important ?
There are two snippets here below, the cmake list and the cmake log, generated after the aboved failed execution. I hope that these are useful.
CMakeLists.txt:
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#
cmake_minimum_required (VERSION 2.6)
set (CMAKE_LEGACY_CYGWIN_WIN32 0)
if (NOT DEFINED CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_NO_WARNINGS)
set (CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_NO_WARNINGS ON)
endif()
if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/VERSION.txt)
file(READ "${CMAKE_CURRENT_SOURCE_DIR}/VERSION.txt" AVRO_VERSION)
else (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/VERSION.txt)
file(READ "${CMAKE_CURRENT_SOURCE_DIR}/../../share/VERSION.txt"
AVRO_VERSION)
endif (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/VERSION.txt)
set (AVRO_VERSION_MAJOR ${AVRO_VERSION})
set (AVRO_VERSION_MINOR "0")
project (Avro-cpp)
if (WIN32 AND NOT CYGWIN AND NOT MSYS)
add_definitions (/EHa)
add_definitions (
-DBOOST_REGEX_DYN_LINK
-DBOOST_FILESYSTEM_DYN_LINK
-DBOOST_SYSTEM_DYN_LINK
-DBOOST_PROGRAM_OPTIONS_DYN_LINK
-DBOOST_ALL_NO_LIB)
endif()
if (CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_CXX_FLAGS "-Wall")
endif ()
find_package (Boost 1.38 REQUIRED
COMPONENTS filesystem system program_options)
add_definitions (${Boost_LIB_DIAGNOSTIC_DEFINITIONS})
include_directories (api ${CMAKE_CURRENT_BINARY_DIR} ${Boost_INCLUDE_DIRS})
set (AVRO_SOURCE_FILES
impl/Compiler.cc impl/Node.cc
impl/NodeImpl.cc impl/ResolverSchema.cc impl/Schema.cc
impl/Types.cc impl/ValidSchema.cc impl/Zigzag.cc
impl/BinaryEncoder.cc impl/BinaryDecoder.cc
impl/Stream.cc impl/FileStream.cc
impl/Generic.cc
impl/DataFile.cc
impl/parsing/Symbol.cc
impl/parsing/ValidatingCodec.cc
impl/parsing/JsonCodec.cc
impl/parsing/ResolvingDecoder.cc
impl/json/JsonIO.cc
impl/json/JsonDom.cc
impl/Resolver.cc impl/Validator.cc
)
add_library (avrocpp SHARED ${AVRO_SOURCE_FILES})
set_property (TARGET avrocpp
APPEND PROPERTY COMPILE_DEFINITIONS AVRO_DYN_LINK)
add_library (avrocpp_s STATIC ${AVRO_SOURCE_FILES})
set_property (TARGET avrocpp avrocpp_s
APPEND PROPERTY COMPILE_DEFINITIONS AVRO_SOURCE)
set_target_properties (avrocpp PROPERTIES
VERSION ${AVRO_VERSION_MAJOR}.${AVRO_VERSION_MINOR})
set_target_properties (avrocpp_s PROPERTIES
VERSION ${AVRO_VERSION_MAJOR}.${AVRO_VERSION_MINOR})
target_link_libraries (avrocpp ${Boost_LIBRARIES})
add_executable (precompile test/precompile.cc)
target_link_libraries (precompile avrocpp_s ${Boost_LIBRARIES})
macro (gencpp file ns)
add_custom_command (OUTPUT ${ns}.hh
COMMAND precompile ${CMAKE_CURRENT_SOURCE_DIR}/jsonschemas/${file}
${file}
COMMAND python ${CMAKE_CURRENT_SOURCE_DIR}/scripts/gen-cppcode.py
-n ${ns} -i ${file} -o ${ns}.hh
DEPENDS precompile ${CMAKE_CURRENT_SOURCE_DIR}/jsonschemas/${file})
add_custom_target(${ns} DEPENDS ${ns}.hh)
endmacro (gencpp)
if (CYGWIN OR NOT WIN32)
gencpp (bigrecord testgen)
gencpp (bigrecord2 testgen2)
endif ()
macro (gen file ns)
add_custom_command (OUTPUT ${file}.hh
COMMAND avrogencpp
-p -
-i ${CMAKE_CURRENT_SOURCE_DIR}/jsonschemas/${file}
-o ${file}.hh -n ${ns} -U
DEPENDS avrogencpp ${CMAKE_CURRENT_SOURCE_DIR}/jsonschemas/${file})
add_custom_target (${file}_hh DEPENDS ${file}.hh)
endmacro (gen)
gen (bigrecord testgen)
gen (bigrecord2 testgen2)
gen (tweet testgen3)
gen (union_array_union uau)
gen (union_map_union umu)
gen (union_conflict uc)
gen (recursive rec)
gen (reuse ru)
gen (circulardep cd)
add_executable (avrogencpp impl/avrogencpp.cc)
target_link_libraries (avrogencpp avrocpp_s ${Boost_LIBRARIES})
enable_testing()
macro (unittest name)
add_executable (${name} test/${name}.cc)
target_link_libraries (${name} avrocpp ${Boost_LIBRARIES})
add_test (NAME ${name} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMAND ${CMAKE_CURRENT_BINARY_DIR}/${name})
endmacro (unittest)
unittest (buffertest)
unittest (unittest)
unittest (SchemaTests)
unittest (CodecTests)
unittest (StreamTests)
unittest (SpecificTests)
unittest (DataFileTests)
unittest (JsonTests)
unittest (AvrogencppTests)
if (CYGWIN OR NOT WIN32)
unittest (testgentest)
add_dependencies (testgentest testgen testgen2)
endif()
add_dependencies (AvrogencppTests bigrecord_hh bigrecord2_hh tweet_hh
union_array_union_hh union_map_union_hh union_conflict_hh
recursive_hh reuse_hh circulardep_hh)
include (InstallRequiredSystemLibraries)
set (CPACK_PACKAGE_FILE_NAME "avrocpp-${AVRO_VERSION_MAJOR}")
include (CPack)
install (TARGETS avrocpp avrocpp_s
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
RUNTIME DESTINATION lib)
install (TARGETS avrogencpp RUNTIME DESTINATION bin)
install (DIRECTORY api/ DESTINATION include/avro
FILES_MATCHING PATTERN *.hh)
if (NOT CMAKE_BUILD_TYPE)
set (CMAKE_BUILD_TYPE Release CACHE STRING
"Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel."
FORCE)
endif (NOT CMAKE_BUILD_TYPE)
and the cmake log:
The system is: Windows - 10.0.10586 - AMD64
Compiling the C compiler identification source file "CMakeCCompilerId.c" succeeded.
Compiler: C:/Program Files (x86)/Visual Studio 14.0/VC/bin/cl.exe
Build flags:
Id flags:
The output was:
0
Microsoft (R) C/C++ Optimizing Compiler Version 19.00.23506 for x86
Copyright (C) Microsoft Corporation. All rights reserved.
CMakeCCompilerId.c
Microsoft (R) Incremental Linker Version 14.00.23506.0
Copyright (C) Microsoft Corporation. All rights reserved.
/out:CMakeCCompilerId.exe
CMakeCCompilerId.obj
Compilation of the C compiler identification source "CMakeCCompilerId.c" produced "CMakeCCompilerId.exe"
Compilation of the C compiler identification source "CMakeCCompilerId.c" produced "CMakeCCompilerId.obj"
The C compiler identification is MSVC, found in "D:/kaa/kaaBuild/avro-src-1.7.5/lang/c++/build.win/CMakeFiles/3.4.3/CompilerIdC/CMakeCCompilerId.exe"
Compiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" succeeded.
Compiler: C:/Program Files (x86)/Visual Studio 14.0/VC/bin/cl.exe
Build flags:
Id flags:
The output was:
0
Microsoft (R) C/C++ Optimizing Compiler Version 19.00.23506 for x86
Copyright (C) Microsoft Corporation. All rights reserved.
CMakeCXXCompilerId.cpp
Microsoft (R) Incremental Linker Version 14.00.23506.0
Copyright (C) Microsoft Corporation. All rights reserved.
/out:CMakeCXXCompilerId.exe
CMakeCXXCompilerId.obj
Compilation of the CXX compiler identification source "CMakeCXXCompilerId.cpp" produced "CMakeCXXCompilerId.exe"
Compilation of the CXX compiler identification source "CMakeCXXCompilerId.cpp" produced "CMakeCXXCompilerId.obj"
The CXX compiler identification is MSVC, found in "D:/kaa/kaaBuild/avro-src-1.7.5/lang/c++/build.win/CMakeFiles/3.4.3/CompilerIdCXX/CMakeCXXCompilerId.exe"
Determining if the C compiler works passed with the following output:
Change Dir: D:/kaa/kaaBuild/avro-src-1.7.5/lang/c++/build.win/CMakeFiles/CMakeTmp
Run Build Command:"nmake" "/NOLOGO" "cmTC_279c3\fast"
"C:\Program Files (x86)\Visual Studio 14.0\VC\BIN\nmake.exe" -f CMakeFiles\cmTC_279c3.dir\build.make /nologo -L CMakeFiles\cmTC_279c3.dir\build
Building C object CMakeFiles/cmTC_279c3.dir/testCCompiler.c.obj
C:\PROGRA~2\VISUAL~1.0\VC\bin\cl.exe #C:\Users\geire\AppData\Local\Temp\nm8C78.tmp
testCCompiler.c
Linking C executable cmTC_279c3.exe
D:\software\cmake_3.4.3\bin\cmake.exe -E vs_link_exe --intdir=CMakeFiles\cmTC_279c3.dir --manifests -- C:\PROGRA~2\VISUAL~1.0\VC\bin\link.exe /nologo #CMakeFiles\cmTC_279c3.dir\objects1.rsp #C:\Users\geire\AppData\Local\Temp\nm8DF0.tmp
Detecting C compiler ABI info compiled with the following output:
Change Dir: D:/kaa/kaaBuild/avro-src-1.7.5/lang/c++/build.win/CMakeFiles/CMakeTmp
Run Build Command:"nmake" "/NOLOGO" "cmTC_f6e85\fast"
"C:\Program Files (x86)\Visual Studio 14.0\VC\BIN\nmake.exe" -f CMakeFiles\cmTC_f6e85.dir\build.make /nologo -L CMakeFiles\cmTC_f6e85.dir\build
Building C object CMakeFiles/cmTC_f6e85.dir/CMakeCCompilerABI.c.obj
C:\PROGRA~2\VISUAL~1.0\VC\bin\cl.exe #C:\Users\geire\AppData\Local\Temp\nm908F.tmp
CMakeCCompilerABI.c
Linking C executable cmTC_f6e85.exe
D:\software\cmake_3.4.3\bin\cmake.exe -E vs_link_exe --intdir=CMakeFiles\cmTC_f6e85.dir --manifests -- C:\PROGRA~2\VISUAL~1.0\VC\bin\link.exe /nologo #CMakeFiles\cmTC_f6e85.dir\objects1.rsp #C:\Users\geire\AppData\Local\Temp\nm90CF.tmp
Determining if the CXX compiler works passed with the following output:
Change Dir: D:/kaa/kaaBuild/avro-src-1.7.5/lang/c++/build.win/CMakeFiles/CMakeTmp
Run Build Command:"nmake" "/NOLOGO" "cmTC_38c4b\fast"
"C:\Program Files (x86)\Visual Studio 14.0\VC\BIN\nmake.exe" -f CMakeFiles\cmTC_38c4b.dir\build.make /nologo -L CMakeFiles\cmTC_38c4b.dir\build
Building CXX object CMakeFiles/cmTC_38c4b.dir/testCXXCompiler.cxx.obj
C:\PROGRA~2\VISUAL~1.0\VC\bin\cl.exe #C:\Users\geire\AppData\Local\Temp\nm92E1.tmp
testCXXCompiler.cxx
Linking CXX executable cmTC_38c4b.exe
D:\software\cmake_3.4.3\bin\cmake.exe -E vs_link_exe --intdir=CMakeFiles\cmTC_38c4b.dir --manifests -- C:\PROGRA~2\VISUAL~1.0\VC\bin\link.exe /nologo #CMakeFiles\cmTC_38c4b.dir\objects1.rsp #C:\Users\geire\AppData\Local\Temp\nm9330.tmp
Detecting CXX compiler ABI info compiled with the following output:
Change Dir: D:/kaa/kaaBuild/avro-src-1.7.5/lang/c++/build.win/CMakeFiles/CMakeTmp
Run Build Command:"nmake" "/NOLOGO" "cmTC_c9164\fast"
"C:\Program Files (x86)\Visual Studio 14.0\VC\BIN\nmake.exe" -f CMakeFiles\cmTC_c9164.dir\build.make /nologo -L CMakeFiles\cmTC_c9164.dir\build
Building CXX object CMakeFiles/cmTC_c9164.dir/CMakeCXXCompilerABI.cpp.obj
C:\PROGRA~2\VISUAL~1.0\VC\bin\cl.exe #C:\Users\geire\AppData\Local\Temp\nm95DE.tmp
CMakeCXXCompilerABI.cpp
Linking CXX executable cmTC_c9164.exe
D:\software\cmake_3.4.3\bin\cmake.exe -E vs_link_exe --intdir=CMakeFiles\cmTC_c9164.dir --manifests -- C:\PROGRA~2\VISUAL~1.0\VC\bin\link.exe /nologo #CMakeFiles\cmTC_c9164.dir\objects1.rsp #C:\Users\geire\AppData\Local\Temp\nm962E.tmp
Detecting CXX [] compiler features compiled with the following output:
Change Dir: D:/kaa/kaaBuild/avro-src-1.7.5/lang/c++/build.win/CMakeFiles/CMakeTmp
Run Build Command:"nmake" "/NOLOGO" "cmTC_2af8b\fast"
"C:\Program Files (x86)\Visual Studio 14.0\VC\BIN\nmake.exe" -f CMakeFiles\cmTC_2af8b.dir\build.make /nologo -L CMakeFiles\cmTC_2af8b.dir\build
Building CXX object CMakeFiles/cmTC_2af8b.dir/feature_tests.cxx.obj
C:\PROGRA~2\VISUAL~1.0\VC\bin\cl.exe #C:\Users\geire\AppData\Local\Temp\nm98CC.tmp
feature_tests.cxx
Linking CXX executable cmTC_2af8b.exe
D:\software\cmake_3.4.3\bin\cmake.exe -E vs_link_exe --intdir=CMakeFiles\cmTC_2af8b.dir --manifests -- C:\PROGRA~2\VISUAL~1.0\VC\bin\link.exe /nologo #CMakeFiles\cmTC_2af8b.dir\objects1.rsp #C:\Users\geire\AppData\Local\Temp\nm992B.tmp
Feature record: CXX_FEATURE:1cxx_alias_templates
Feature record: CXX_FEATURE:1cxx_alignas
Feature record: CXX_FEATURE:1cxx_alignof
Feature record: CXX_FEATURE:1cxx_attributes
Feature record: CXX_FEATURE:1cxx_attribute_deprecated
Feature record: CXX_FEATURE:1cxx_auto_type
Feature record: CXX_FEATURE:1cxx_binary_literals
Feature record: CXX_FEATURE:1cxx_constexpr
Feature record: CXX_FEATURE:1cxx_contextual_conversions
Feature record: CXX_FEATURE:1cxx_decltype
Feature record: CXX_FEATURE:1cxx_decltype_auto
Feature record: CXX_FEATURE:1cxx_default_function_template_args
Feature record: CXX_FEATURE:1cxx_defaulted_functions
Feature record: CXX_FEATURE:1cxx_defaulted_move_initializers
Feature record: CXX_FEATURE:1cxx_delegating_constructors
Feature record: CXX_FEATURE:1cxx_deleted_functions
Feature record: CXX_FEATURE:1cxx_digit_separators
Feature record: CXX_FEATURE:1cxx_enum_forward_declarations
Feature record: CXX_FEATURE:1cxx_explicit_conversions
Feature record: CXX_FEATURE:1cxx_extended_friend_declarations
Feature record: CXX_FEATURE:1cxx_extern_templates
Feature record: CXX_FEATURE:1cxx_final
Feature record: CXX_FEATURE:1cxx_func_identifier
Feature record: CXX_FEATURE:1cxx_generalized_initializers
Feature record: CXX_FEATURE:1cxx_generic_lambdas
Feature record: CXX_FEATURE:1cxx_inheriting_constructors
Feature record: CXX_FEATURE:1cxx_inline_namespaces
Feature record: CXX_FEATURE:1cxx_lambdas
Feature record: CXX_FEATURE:1cxx_lambda_init_captures
Feature record: CXX_FEATURE:1cxx_local_type_template_args
Feature record: CXX_FEATURE:1cxx_long_long_type
Feature record: CXX_FEATURE:1cxx_noexcept
Feature record: CXX_FEATURE:1cxx_nonstatic_member_init
Feature record: CXX_FEATURE:1cxx_nullptr
Feature record: CXX_FEATURE:1cxx_override
Feature record: CXX_FEATURE:1cxx_range_for
Feature record: CXX_FEATURE:1cxx_raw_string_literals
Feature record: CXX_FEATURE:1cxx_reference_qualified_functions
Feature record: CXX_FEATURE:1cxx_return_type_deduction
Feature record: CXX_FEATURE:1cxx_right_angle_brackets
Feature record: CXX_FEATURE:1cxx_rvalue_references
Feature record: CXX_FEATURE:1cxx_sizeof_member
Feature record: CXX_FEATURE:1cxx_static_assert
Feature record: CXX_FEATURE:1cxx_strong_enums
Feature record: CXX_FEATURE:1cxx_template_template_parameters
Feature record: CXX_FEATURE:1cxx_thread_local
Feature record: CXX_FEATURE:1cxx_trailing_return_types
Feature record: CXX_FEATURE:1cxx_unicode_literals
Feature record: CXX_FEATURE:1cxx_uniform_initialization
Feature record: CXX_FEATURE:1cxx_unrestricted_unions
Feature record: CXX_FEATURE:1cxx_user_literals
Feature record: CXX_FEATURE:1cxx_variadic_macros
Feature record: CXX_FEATURE:1cxx_variadic_templates

Why NMake generator puts the .obj file for C files in a directory other than those of C ++

I've a mysterious problem with the "NMake Makefiles" generator.
When I used my CMakeLists for generate a Solution Visual and I build after, he puts all my .obj in the same folder "sql_lite.dir/Debug/". The build success.
But when I use the Nmake generator, he put my .obj in 2 diferent folder :
sql_sqlite.dir/C_/Users/mea/Documents/repos/corealpi/external/sqlite
and
sql_sqlite.dir/C_/Users/mea/Documents/repos/corealpi/external/sqlite/sqlite3.c.obj
I thought the fact I have file.cpp and file.c is the problem of my issue, because I have the following output :
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Configuring done
CMake Error: Error required internal CMake variable not set, cmake may be not be built correctly.
Missing variable is:
CMAKE_C_COMPILE_OBJECT
And this at the end of Nmake :
[100%] Building C object CMakeFiles/sql_sqlite.dir/C_/Users/mea/Documents/repos/
corealpi/external/sqlite/sqlite3.c.obj
Linking CXX shared library C:\Users\mea\Documents\repos\corealpi\build\cmake_x86
d\bin\sql_sqlite.dll
LINK : fatal error LNK1104: cannot open file 'CMakeFiles/sql_sqlite.dir/C_/Users
/mea/Documents/repos/corealpi/external/sqlite/sqlite3.c.obj'
LINK failed. with 1104
It seems, he not build in the same directory and not build the .obj for the C file's.
Here is my CMakeLists.txt (who's running well under Visual Studio) :
############################### SQLITE ###############################
project(sql_sqlite CXX)
SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /MANIFEST:NO")
# Path of Release
SET(BIN_RELEASE_PATH "../../build/cmake_x86")
SET( CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE "${BIN_RELEASE_PATH}/bin/" )
SET( CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE "${BIN_RELEASE_PATH}/bin/" )
SET( CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE "${BIN_RELEASE_PATH}/bin/" )
# Path of Debug
SET(BIN_DEBUG_PATH "../../build/cmake_x86d")
SET( CMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG "${BIN_DEBUG_PATH}/bin/" )
SET( CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG "${BIN_DEBUG_PATH}/bin/" )
SET( CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG "${BIN_DEBUG_PATH}/bin/" )
# Flags
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4 /Ycstdafx.h /Yustdafx.h /D_USRDLL /DSQL_SQLITE_EXPORTS /D_UNICODE /DUNICODE")
SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Zi /GL /Oi /Gy /O2 /GR- /Gm- /OPT /Fosql_sqlite.dir/src/sql_sqlite")
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /WX- /ZI /Oy- /Gm /EHsc /MDd /GS /Gd")
set_source_files_properties(../datasec/src/sql_sqlite/stdafx.cpp PROPERTIES COMPILE_FLAGS "/Ycstdafx.h")
set_source_files_properties(../datasec/src/sql_sqlite/main.cpp PROPERTIES COMPILE_FLAGS "/Yustdafx.h")
set_source_files_properties(../external/sqlite/sqlite3.c PROPERTIES COMPILE_FLAGS "/Y-")
# Files of library
add_library(
sql_sqlite
SHARED
../datasec/src/sql_sqlite/stdafx.h
../external/sqlite/sqlite3.h
../datasec/src/sql_sqlite/sql_sqlite.cpp
../datasec/src/sql_sqlite/stdafx.cpp
../datasec/src/sql_sqlite/main.cpp
../external/sqlite/sqlite3.c
)
target_link_libraries(sql_sqlite datasec core)
Please I need help because, I've search on many website, try different solution during many days but anyway, it stand failing linking.
I've trying to put something like that : /Fosql_sqlite.dir/src/sql_sqlite but nothing change.
Do I have to make a special rule for sqlite3.c ? Or have I make something wrong on my CMakeLists.txt ?
Why CMake tells me : Missing variable is: CMAKE_C_COMPILE_OBJECT ?
Thanks for help.
Your PROJECT lines specifes C++ only via the CXX. Maybe removing the CXX will fix the problem so that both C and C++ compilers will be setup. The documentation is here, http://www.cmake.org/cmake/help/v3.2/command/project.html