Closed OptoCloud closed 4 years ago
Ah interesting, this would also affect Unix since hard links are not allowed to cross fs boundary.
Workaround pass --link-method=copy
Probably we want to stop using hardlink unless explicitly requested by user. Or alternately test to see if it is possible, and if not fall back to copy.
I use QTCreator with CMake and can't reproduce, although I have a custom .cmake file only for Botan. Let me know if you need it.
ETA: On Linux.
I use QTCreator with CMake and can't reproduce, although I have a custom .cmake file only for Botan. Let me know if you need it.
ETA: On Linux.
I ended up with this for building the CMake library used by both the server and the client:
cmake_minimum_required(VERSION 3.5)
set(project StaticLib)
project(
${project}
DESCRIPTION "Library that is used by both the server and the client"
LANGUAGES CXX
)
message("Configuring ${project}...")
if(UNIX AND NOT APPLE)
set(LINUX TRUE)
set(OS_STR "Linux")
elseif(WIN32)
set(WINDOWS TRUE)
set(OS_STR "Windows")
endif()
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
if(LINUX)
# 64-bit, threading, and verbose
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m64 -pthread -Wall -Wextra -pedantic")
if(${CMAKE_BUILD_TYPE} MATCHES "Release")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fstack-protector -O3 -g0")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O0 -g3")
endif()
# Very verbose!
if (VERBOSE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --verbose")
endif()
elseif(WINDOWS)
if(${CMAKE_BUILD_TYPE} MATCHES "Release")
set(WIN_DEBUG_FLAG "/DEBUG:NONE")
set(WIN_OPTIMIZATION_FLAG "/O2")
else()
set(WIN_DEBUG_FLAG "/DEBUG:FULL")
set(WIN_OPTIMIZATION_FLAG "/Od")
endif()
# Stop botan from f****** up
add_definitions(/DNOMINMAX /DBOTAN_IS_BEING_BUILT)
# Force to always compile with W4
if(CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
string(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4")
endif()
# Force to always compile with MT
if(CMAKE_CXX_FLAGS MATCHES "/MDd?|/MTd?|/LDd?")
string(REGEX REPLACE "/MDd?|/MTd?|/LDd?" "/MT" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MT")
endif()
# Force to always compile with /O2 or /Od
if(CMAKE_CXX_FLAGS MATCHES "/O.?")
string(REGEX REPLACE "/O.?" ${WIN_OPTIMIZATION_FLAG} CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${WIN_OPTIMIZATION_FLAG}")
endif()
# Force to always compile with DEBUG:XXXX
if(CMAKE_CXX_FLAGS MATCHES "/DEBUG\:[^\\s]+")
string(REGEX REPLACE "/DEBUG\:[^\\s]+" ${WIN_DEBUG_FLAG} CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${WIN_DEBUG_FLAG}")
endif()
# Botan build is pretty big
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /bigobj")
endif()
if (NOT EXISTS ${CMAKE_BINARY_DIR}/botan_all.h)
# Set OS specific arguments
if(LINUX)
set(BUILD_OS "linux")
set(BUILD_COMPILER "gcc")
elseif(WINDOWS)
set(BUILD_OS "windows")
set(BUILD_COMPILER "msvc")
endif()
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(BUILD_ARCH "x86_64")
elseif(CMAKE_SIZEOF_VOID_P EQUAL 4)
set(BUILD_ARCH "i386")
endif()
# Set python initial arguments
set(PYTHON_ARGS
"${CMAKE_CURRENT_SOURCE_DIR}/botan/configure.py"
"--os=${BUILD_OS}"
"--cc=${BUILD_COMPILER}"
"--cpu=${BUILD_ARCH}"
"--amalgamation"
"--disable-shared"
"--link-method=copy"
"--disable-modules=pkcs11"
"--without-documentation"
)
# Crossing fingers....
execute_process(
COMMAND "python" ${PYTHON_ARGS}
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
RESULT_VARIABLE py_result
OUTPUT_VARIABLE py_output
)
# Print the output
message("BUILD OUTPUT:\n${py_output}")
# If it returned something else than 0 it probably didnt succeed
if (NOT ${py_result} EQUAL 0)
message(FATAL_ERROR "Failed to build Botan")
endif()
endif()
add_library(${project} STATIC
${CMAKE_BINARY_DIR}/botan_all.cpp
${CMAKE_BINARY_DIR}/botan_all.h
${CMAKE_CURRENT_SOURCE_DIR}/enums.h
${CMAKE_CURRENT_SOURCE_DIR}/constants.h
${CMAKE_CURRENT_SOURCE_DIR}/message.cpp
${CMAKE_CURRENT_SOURCE_DIR}/message.h
${CMAKE_CURRENT_SOURCE_DIR}/crypto.cpp
${CMAKE_CURRENT_SOURCE_DIR}/crypto.h
${CMAKE_CURRENT_SOURCE_DIR}/enet/include/enet.h
)
set(LIB_INC_DIRS
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/enet/include
${CMAKE_BINARY_DIR}
CACHE PATH "List of library directories for header includes"
)
include_directories(${LIB_INC_DIRS})
if(WINDOWS)
target_link_libraries(${project} Crypt32)
endif()
Was building on windows using CMake and QtCreator (works fine with VS2019) and i got this error (which clearly isnt a linking error):
Output from QtCreator:
Output from VS2019:
The files were not altered between the builds