@@ -3,6 +3,18 @@
|
||||
|
||||
cmake_minimum_required(VERSION 3.1)
|
||||
|
||||
if(MSVC)
|
||||
if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.15")
|
||||
# set all policies to max supported by actual running cmake version
|
||||
# mainly want the following:
|
||||
# CMP0091: prevent msvcrt flags being added to default CMAKE_<LANG>_FLAGS_<CONFIG>
|
||||
# CMP0092: prevent warning flags being added to default CMAKE_<LANG>_FLAGS
|
||||
cmake_policy(VERSION ${CMAKE_VERSION})
|
||||
else()
|
||||
message(FATAL_ERROR "please update cmake")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Workaround to fix wrong compiler on macos.
|
||||
if(APPLE AND NOT CMAKE_C_COMPILER)
|
||||
set(CMAKE_C_COMPILER "/usr/bin/cc")
|
||||
@@ -12,13 +24,16 @@ endif()
|
||||
set(PROJECT_IS_TOP_LEVEL OFF)
|
||||
if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
|
||||
set(PROJECT_IS_TOP_LEVEL ON)
|
||||
|
||||
|
||||
# Enable folder support
|
||||
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
|
||||
endif()
|
||||
|
||||
project(unicorn C)
|
||||
|
||||
# mainline qemu mostly just uses compiler default
|
||||
set(CMAKE_C_STANDARD 11)
|
||||
|
||||
set(UNICORN_VERSION_MAJOR 2)
|
||||
set(UNICORN_VERSION_MINOR 0)
|
||||
set(UNICORN_VERSION_PATCH 0)
|
||||
@@ -63,6 +78,7 @@ if(MSVC)
|
||||
else()
|
||||
message(FATAL_ERROR "Neither WIN64 or WIN32!")
|
||||
endif()
|
||||
|
||||
add_compile_options(
|
||||
-Dinline=__inline
|
||||
-D__func__=__FUNCTION__
|
||||
@@ -71,22 +87,30 @@ if(MSVC)
|
||||
${MSVC_FLAG}
|
||||
/I${CMAKE_CURRENT_SOURCE_DIR}/qemu/tcg/i386
|
||||
)
|
||||
|
||||
# Disable some warnings
|
||||
add_compile_options(
|
||||
/wd4018
|
||||
/wd4098
|
||||
/wd4244
|
||||
/wd4267
|
||||
)
|
||||
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||
string(REPLACE "/ZI" "/Zi" CMAKE_C_FLAGS_DEBUG ${CMAKE_C_FLAGS_DEBUG})
|
||||
add_compile_options($<$<COMPILE_LANGUAGE:C>:/wd4018>)
|
||||
add_compile_options($<$<COMPILE_LANGUAGE:C>:/wd4098>)
|
||||
add_compile_options($<$<COMPILE_LANGUAGE:C>:/wd4244>)
|
||||
add_compile_options($<$<COMPILE_LANGUAGE:C>:/wd4267>)
|
||||
|
||||
# handle msvcrt setting being passed in CMAKE_C_FLAGS
|
||||
if(DEFINED CMAKE_MSVC_RUNTIME_LIBRARY)
|
||||
# do not support other methods of setting this (it would be more conformant, tho)
|
||||
message(FATAL_ERROR "please set msvcrt via CMAKE_C_FLAGS")
|
||||
endif()
|
||||
# default use the multithread, static version of the run-time library.
|
||||
option(UNICORN_STATIC_MSVCRT "Embed static runtime library" ${PROJECT_IS_TOP_LEVEL})
|
||||
if(UNICORN_STATIC_MSVCRT)
|
||||
string(REPLACE "/MD" "/MT" CMAKE_C_FLAGS_DEBUG ${CMAKE_C_FLAGS_DEBUG})
|
||||
string(REPLACE "/MD" "/MT" CMAKE_C_FLAGS_RELEASE ${CMAKE_C_FLAGS_RELEASE})
|
||||
if(CMAKE_C_FLAGS MATCHES "[/-]MTd")
|
||||
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreadedDebug")
|
||||
elseif(CMAKE_C_FLAGS MATCHES "[/-]MDd")
|
||||
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreadedDebugDLL")
|
||||
elseif(CMAKE_C_FLAGS MATCHES "[/-]MT")
|
||||
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded")
|
||||
elseif(CMAKE_C_FLAGS MATCHES "[/-]MD")
|
||||
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreadedDLL")
|
||||
endif()
|
||||
|
||||
# prevent the arg from occurring more than once (not a big deal, just to keep tidy)
|
||||
string(REGEX REPLACE "[/-]M[TD]d?" "" CMAKE_C_FLAGS ${CMAKE_C_FLAGS})
|
||||
else()
|
||||
if(MINGW)
|
||||
execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpmachine
|
||||
@@ -1181,7 +1205,7 @@ if(UNICORN_TRACER)
|
||||
target_compile_options(unicorn PRIVATE -DUNICORN_TRACER)
|
||||
endif()
|
||||
|
||||
target_compile_options(unicorn-common PRIVATE
|
||||
target_compile_options(unicorn-common PRIVATE
|
||||
${UNICORN_COMPILE_OPTIONS}
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user