mirror of
				https://github.com/vcmi/vcmi.git
				synced 2025-10-31 00:07:39 +02:00 
			
		
		
		
	[conan] add MSVC support
also removes all mentions of vcpkg and cross-building from Linux
This commit is contained in:
		| @@ -19,10 +19,6 @@ else() | ||||
| 	set(fuzzylite_FOUND FALSE) | ||||
| endif() | ||||
|  | ||||
| if(TARGET fuzzylite::fuzzylite AND MSVC) | ||||
| 	install_vcpkg_imported_tgt(fuzzylite::fuzzylite) | ||||
| endif() | ||||
|  | ||||
| if(NOT fuzzylite_FOUND) | ||||
| 	set(FL_BUILD_BINARY OFF CACHE BOOL "") | ||||
| 	set(FL_BUILD_SHARED OFF CACHE BOOL "") | ||||
|   | ||||
							
								
								
									
										21
									
								
								CI/conan/base/msvc
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										21
									
								
								CI/conan/base/msvc
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,21 @@ | ||||
| include(common) | ||||
|  | ||||
| [settings] | ||||
| compiler=msvc | ||||
| compiler.cppstd=17 | ||||
| compiler.runtime=dynamic | ||||
| compiler.version=194 | ||||
| os=Windows | ||||
|  | ||||
| [conf] | ||||
| # https://walbourn.github.io/a-brief-history-of-windows-sdks/ | ||||
| # https://learn.microsoft.com/en-us/cpp/porting/modifying-winver-and-win32-winnt | ||||
| # https://learn.microsoft.com/en-us/windows/win32/WinProg/using-the-windows-headers | ||||
| {% set _WIN32_WINNT_WIN7 = '0x0601' %} | ||||
| {% set NTDDI_WIN7 = '0x06010000' %} | ||||
| {% set win7_defines = [ | ||||
|     '_WIN32_WINNT={}'.format(_WIN32_WINNT_WIN7), | ||||
|     'WINVER={}'.format(_WIN32_WINNT_WIN7), | ||||
|     'NTDDI_VERSION={}'.format(NTDDI_WIN7), | ||||
| ] %} | ||||
| tools.build:defines={{ win7_defines }} | ||||
							
								
								
									
										4
									
								
								CI/conan/msvc-x64
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										4
									
								
								CI/conan/msvc-x64
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,4 @@ | ||||
| include(base/msvc) | ||||
|  | ||||
| [settings] | ||||
| arch=x86_64 | ||||
							
								
								
									
										4
									
								
								CI/conan/msvc-x86
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										4
									
								
								CI/conan/msvc-x86
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,4 @@ | ||||
| include(base/msvc) | ||||
|  | ||||
| [settings] | ||||
| arch=x86 | ||||
| @@ -310,7 +310,7 @@ endif() | ||||
|  | ||||
| if(MINGW OR MSVC) | ||||
| 	# Windows Vista or newer for FuzzyLite 6 to compile | ||||
| 	# Except for conan which already has this definition in its preset | ||||
| 	# Except for conan which already has this definition in its profile | ||||
| 	if(NOT USING_CONAN) | ||||
| 		add_definitions(-D_WIN32_WINNT=0x0600) | ||||
| 	endif() | ||||
| @@ -373,14 +373,9 @@ if(MINGW OR MSVC) | ||||
| 		# Reported to Microsoft here: | ||||
| 		# https://developercommunity.visualstudio.com/content/problem/224597/linker-failing-because-of-multiple-definitions-of.html | ||||
| 		set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /FORCE:MULTIPLE") | ||||
|  | ||||
| 		# Required at least for compatibility with Boost 1.68 on Vcpkg | ||||
|   		# psapi required for ARM64 builds | ||||
| 		set(SYSTEM_LIBS ${SYSTEM_LIBS} bcrypt psapi) | ||||
| 	endif(MSVC) | ||||
|  | ||||
| 	if(MINGW) | ||||
|  | ||||
| 		# Temporary (?) workaround for failing builds on MinGW CI due to bug in TBB | ||||
| 		set(CMAKE_CXX_EXTENSIONS ON) | ||||
|  | ||||
| @@ -779,59 +774,6 @@ if(NOT WIN32 AND NOT APPLE_IOS AND NOT ANDROID) | ||||
| 					WORLD_READ WORLD_EXECUTE) | ||||
| endif() | ||||
|  | ||||
|  | ||||
| if(WIN32) | ||||
| 	if(TBB_FOUND AND MSVC) | ||||
| 		install_vcpkg_imported_tgt(TBB::tbb) | ||||
| 	endif() | ||||
|  | ||||
| 	if(USING_CONAN) | ||||
| 		#Conan imports enabled | ||||
| 		vcmi_install_conan_deps("\${CMAKE_INSTALL_PREFIX}") | ||||
| 		file(GLOB dep_files | ||||
| 				${dep_files} | ||||
| 				"${CMAKE_SYSROOT}/bin/*.dll"  | ||||
| 				"${CMAKE_SYSROOT}/lib/*.dll"  | ||||
| 				"${CONAN_SYSTEM_LIBRARY_LOCATION}/libgcc_s_dw2-1.dll" # for 32-bit only? | ||||
| 				"${CONAN_SYSTEM_LIBRARY_LOCATION}/libgcc_s_seh-1.dll" # for 64-bit only? | ||||
| 				"${CONAN_SYSTEM_LIBRARY_LOCATION}/libstdc++-6.dll") | ||||
| 	else() | ||||
| 		file(GLOB dep_files | ||||
| 				${dep_files} | ||||
| 				"${CMAKE_FIND_ROOT_PATH}/bin/*.dll") | ||||
| 	endif() | ||||
|  | ||||
| 	if(CMAKE_BUILD_TYPE STREQUAL "Debug") | ||||
| 		# Copy debug versions of libraries if build type is debug | ||||
| 		set(debug_postfix d) | ||||
| 	endif() | ||||
|  | ||||
| 	if(ENABLE_LAUNCHER OR ENABLE_EDITOR) | ||||
| 		get_target_property(QtCore_location Qt${QT_VERSION_MAJOR}::Core LOCATION) | ||||
| 		get_filename_component(Qtbin_folder ${QtCore_location} PATH) | ||||
| 		file(GLOB dep_files | ||||
| 			${dep_files} | ||||
| 			${Qtbin_folder}/Qt5Core${debug_postfix}.dll | ||||
| 			${Qtbin_folder}/Qt5Gui${debug_postfix}.dll | ||||
| 			${Qtbin_folder}/Qt5Widgets${debug_postfix}.dll | ||||
| 			${Qtbin_folder}/Qt5Network${debug_postfix}.dll | ||||
| 			${Qtbin_folder}/icu*.dll) | ||||
| 		get_target_property(integration_type Qt${QT_VERSION_MAJOR}::QWindowsIntegrationPlugin TYPE) | ||||
| 		if(NOT(integration_type STREQUAL "INTERFACE_LIBRARY")) | ||||
| 			get_target_property(integration_loc Qt${QT_VERSION_MAJOR}::QWindowsIntegrationPlugin LOCATION) | ||||
| 			install( | ||||
| 				FILES ${integration_loc} | ||||
| 				DESTINATION ${BIN_DIR}/platforms | ||||
| 			) | ||||
| 			install( | ||||
| 				FILES "$<TARGET_FILE:Qt${QT_VERSION_MAJOR}::QWindowsVistaStylePlugin>"  | ||||
| 				DESTINATION ${BIN_DIR}/styles)  | ||||
| 		endif() | ||||
| 	endif() | ||||
|  | ||||
| 	install(FILES ${dep_files} DESTINATION ${BIN_DIR}) | ||||
| endif(WIN32) | ||||
|  | ||||
| ####################################### | ||||
| #       Packaging section             # | ||||
| ####################################### | ||||
|   | ||||
| @@ -30,6 +30,7 @@ if(ANDROID) | ||||
| 	) | ||||
| else() | ||||
| 	add_executable(vcmiclient ${clientapp_SRCS} ${clientapp_HEADERS}) | ||||
| 	vcmi_create_exe_shim(vcmiclient) | ||||
| endif() | ||||
|  | ||||
| target_link_libraries(vcmiclient PRIVATE vcmiclientcommon) | ||||
| @@ -55,15 +56,6 @@ if(WIN32) | ||||
| 		target_link_libraries(vcmiclient SDL2::SDL2main) | ||||
| 	endif() | ||||
| 	target_compile_definitions(vcmiclient PRIVATE WINDOWS_IGNORE_PACKING_MISMATCH) | ||||
|  | ||||
| 	# TODO: very hacky, find proper solution to copy AI dlls into bin dir | ||||
| 	if(MSVC) | ||||
| 		add_custom_command(TARGET vcmiclient POST_BUILD | ||||
| 			WORKING_DIRECTORY "$<TARGET_FILE_DIR:vcmiclient>" | ||||
| 			COMMAND ${CMAKE_COMMAND} -E copy AI/fuzzylite.dll fuzzylite.dll | ||||
| 			COMMAND ${CMAKE_COMMAND} -E copy AI/tbb12.dll tbb12.dll | ||||
| 		) | ||||
| 	endif() | ||||
| elseif(APPLE_IOS) | ||||
| 	set_target_properties(vcmiclient PROPERTIES | ||||
| 		MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_LIST_DIR}/ios/Info.plist" | ||||
|   | ||||
| @@ -118,16 +118,6 @@ function(vcmi_print_git_commit_hash) | ||||
|  | ||||
| endfunction() | ||||
|  | ||||
| #install imported target on windows | ||||
| function(install_vcpkg_imported_tgt tgt) | ||||
| 	get_target_property(TGT_LIB_LOCATION ${tgt} LOCATION) | ||||
| 	get_filename_component(TGT_LIB_FOLDER ${TGT_LIB_LOCATION} PATH) | ||||
| 	get_filename_component(tgt_name ${TGT_LIB_LOCATION} NAME_WE) | ||||
| 	get_filename_component(TGT_DLL ${TGT_LIB_FOLDER}/../bin/${tgt_name}.dll ABSOLUTE) | ||||
| 	message("${tgt_name}: ${TGT_DLL}") | ||||
| 	install(FILES ${TGT_DLL} DESTINATION ${BIN_DIR}) | ||||
| endfunction(install_vcpkg_imported_tgt) | ||||
|  | ||||
| # install dependencies from Conan, CONAN_RUNTIME_LIBS_FILE is set in conanfile.py | ||||
| function(vcmi_install_conan_deps) | ||||
| 	if(NOT USING_CONAN) | ||||
| @@ -149,3 +139,14 @@ function(vcmi_deploy_qt deployQtToolName deployQtOptions) | ||||
| 		message(WARNING "${deployQtToolName} not found, running cpack would result in broken package") | ||||
| 	endif() | ||||
| endfunction() | ||||
|  | ||||
| # generate .bat for .exe with proper PATH | ||||
| function(vcmi_create_exe_shim tgt) | ||||
| 	if(NOT CONAN_RUNENV_SCRIPT) | ||||
| 		return() | ||||
| 	endif() | ||||
| 	file(GENERATE OUTPUT "$<TARGET_FILE_DIR:${tgt}>/$<TARGET_FILE_BASE_NAME:${tgt}>.bat" CONTENT | ||||
| "call ${CONAN_RUNENV_SCRIPT} | ||||
| @start $<TARGET_FILE_NAME:${tgt}>" | ||||
| 	) | ||||
| endfunction() | ||||
|   | ||||
| @@ -155,6 +155,7 @@ if(ENABLE_SINGLE_APP_BUILD OR ANDROID) | ||||
| 	add_library(vcmilauncher OBJECT ${launcher_QM}) | ||||
| else() | ||||
| 	add_executable(vcmilauncher WIN32 ${launcher_QM} ${launcher_ICON}) | ||||
| 	vcmi_create_exe_shim(vcmilauncher) | ||||
| endif() | ||||
|  | ||||
| if(ENABLE_TRANSLATIONS) | ||||
|   | ||||
| @@ -258,6 +258,7 @@ if(ENABLE_SINGLE_APP_BUILD OR ANDROID) | ||||
| 	add_library(vcmieditor OBJECT ${editor_QM}) | ||||
| else() | ||||
| 	add_executable(vcmieditor WIN32 ${editor_QM} ${editor_SRCS} ${editor_HEADERS} ${editor_UI_HEADERS} ${editor_ICON}) | ||||
| 	vcmi_create_exe_shim(vcmieditor) | ||||
| endif() | ||||
|  | ||||
| if(ENABLE_TRANSLATIONS) | ||||
|   | ||||
| @@ -9,6 +9,7 @@ set(serverapp_HEADERS | ||||
|  | ||||
| assign_source_group(${serverapp_SRCS} ${serverapp_HEADERS}) | ||||
| add_executable(vcmiserver ${serverapp_SRCS} ${serverapp_HEADERS}) | ||||
| vcmi_create_exe_shim(vcmiserver) | ||||
|  | ||||
| set(serverapp_LIBS vcmi) | ||||
| if(CMAKE_SYSTEM_NAME MATCHES FreeBSD OR HAIKU) | ||||
|   | ||||
| @@ -1,43 +1,10 @@ | ||||
| # We need to keep this code into separate directory so CMake will execute it after all other subdirectories install code | ||||
| # Otherwise we can't fix win bundle dependencies since binaries wouldn't be there when this code executed | ||||
| # This will likely only work for Vcpkg | ||||
| if(WIN32) | ||||
| 	#there are some weird issues with variables used in path not evaluated properly when trying to remove code duplication from below lines | ||||
| 	 | ||||
| 	if(ENABLE_LAUNCHER) | ||||
| 		install(CODE "			 | ||||
| 			file(WRITE \"\${CMAKE_INSTALL_PREFIX}/qt.conf\" | ||||
| 				\"[Paths]\nPlugins = .\" | ||||
| 			) | ||||
| 		") | ||||
| if(WIN32 AND (ENABLE_LAUNCHER OR ENABLE_EDITOR)) | ||||
| 	if(TARGET vcmilauncher) | ||||
| 		set(deployTarget vcmilauncher) | ||||
| 	elseif(TARGET vcmieditor) | ||||
| 		set(deployTarget vcmieditor) | ||||
| 	endif() | ||||
|  | ||||
| 	 | ||||
| 	#TODO: check if some equivalent of block below can be used for above block (easy qt dependencies copy) | ||||
| 	#LuaJIT will not be copied automatically by not meeting criteria for this block of code | ||||
| 	if(ENABLE_LUA) | ||||
| 		install_vcpkg_imported_tgt(luajit::luajit) | ||||
| 	endif() | ||||
| 	 | ||||
| 	if(MSVC) | ||||
| 		set(gp_tool "dumpbin") | ||||
| 	endif() | ||||
|  | ||||
| 	install(CODE " | ||||
| 		set(dirs \"${CMAKE_PREFIX_PATH}\") | ||||
| 		if(\"\${CMAKE_INSTALL_CONFIG_NAME}\" STREQUAL \"Debug\") | ||||
| 			list(TRANSFORM dirs APPEND \"/debug/bin\") | ||||
| 		else() | ||||
| 			list(TRANSFORM dirs APPEND \"/bin\") | ||||
| 			list(FILTER dirs EXCLUDE REGEX \".*debug.*\") | ||||
| 		endif() | ||||
| 		 | ||||
| 		set(BU_CHMOD_BUNDLE_ITEMS ON) | ||||
| 		set(gp_tool \"${gp_tool}\") | ||||
| 		 | ||||
| 		include(BundleUtilities) | ||||
|  | ||||
| 		fixup_bundle(\"\${CMAKE_INSTALL_PREFIX}/VCMI_Client.exe\" \"\" \"\${dirs}\") | ||||
|  | ||||
| 	" COMPONENT Runtime) | ||||
| endif(WIN32) | ||||
| 	set(targetBinary "\"\${CMAKE_INSTALL_PREFIX}/${BIN_DIR}/$<TARGET_FILE_NAME:${deployTarget}>\"") | ||||
| 	vcmi_deploy_qt(windeployqt "--no-compiler-runtime ${targetBinary}") | ||||
| endif() | ||||
|   | ||||
		Reference in New Issue
	
	Block a user