Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions src/mono/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,9 @@ elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
set(HOST_LINUX 1)
add_definitions(-D_GNU_SOURCE -D_REENTRANT)
add_definitions(-D_THREAD_SAFE)
# Enable the "full RELRO" options (RELRO & BIND_NOW) at link time
add_link_options(-Wl,-z,relro)
add_link_options(-Wl,-z,now)
elseif(CMAKE_SYSTEM_NAME STREQUAL "Android")
set(HOST_LINUX 1)
add_definitions(-D_GNU_SOURCE -D_REENTRANT)
Expand Down Expand Up @@ -724,11 +727,13 @@ endif()
######################################
# EXTRACT VERSION
######################################
if(NOT EXISTS "${CMAKE_CURRENT_BINARY_DIR}/_version.h")
if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows")
if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows")
if(NOT EXISTS "${CMAKE_CURRENT_BINARY_DIR}/_version.h")
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/_version.h" "#undef VER_PRODUCTVERSION_STR\n#define VER_PRODUCTVERSION_STR \"42.42.42.42424\"\n")
else()
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/_version.h" "static char sccsid[] __attribute__((used)) = \"@(#)Version 42.42.42.42424 @Commit: AAA\";\n")
endif()
else()
if(NOT EXISTS "${CMAKE_CURRENT_BINARY_DIR}/version.c")
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/version.c" "static char sccsid[] __attribute__((used)) = \"@(#)Version 42.42.42.42424 @Commit: AAA\";\n")
endif()
endif()
if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows" AND NOT EXISTS "${CMAKE_CURRENT_BINARY_DIR}/NativeVersion.rc")
Expand All @@ -750,7 +755,7 @@ if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows")
file(STRINGS "${CMAKE_CURRENT_BINARY_DIR}/_version.h" product_version_string_line REGEX "VER_PRODUCTVERSION_STR ")
string(REGEX REPLACE ".*VER_PRODUCTVERSION_STR *(.*)" "\\1" product_version_string ${product_version_string_line})
else()
file(STRINGS "${CMAKE_CURRENT_BINARY_DIR}/_version.h" product_version_string_line REGEX "sccsid")
file(STRINGS "${CMAKE_CURRENT_BINARY_DIR}/version.c" product_version_string_line REGEX "sccsid")
string(REGEX REPLACE ".*Version *(.*)\";" "\"\\1\"" product_version_string ${product_version_string_line})
endif()

Expand Down
9 changes: 7 additions & 2 deletions src/mono/mono.proj
Original file line number Diff line number Diff line change
Expand Up @@ -724,13 +724,18 @@
</Target>

<Target Name="GenerateMonoVersionFile" DependsOnTargets="InitializeGenerateRuntimeVersionFile">
<PropertyGroup>
<NativeVersionFile Condition="'$(OS)' == 'Windows_NT'">_version.h</NativeVersionFile>
<NativeVersionFile Condition="'$(OS)' != 'Windows_NT'">version.c</NativeVersionFile>
</PropertyGroup>

<MSBuild Projects="$(RepoRoot)eng\empty.csproj"
Targets="GenerateRuntimeVersionFile"
Properties="NativeVersionFile=$(MonoObjDir)_version.h;RuntimeVersionFile=$(MonoObjDir)runtime_version.h" />
Properties="NativeVersionFile=$(MonoObjDir)$(NativeVersionFile);RuntimeVersionFile=$(MonoObjDir)runtime_version.h" />
<MSBuild Condition="'$(BuildMonoAOTCrossCompiler)' == 'true'"
Projects="$(RepoRoot)eng\empty.csproj"
Targets="GenerateRuntimeVersionFile"
Properties="NativeVersionFile=$(MonoObjCrossDir)_version.h;RuntimeVersionFile=$(MonoObjCrossDir)runtime_version.h" />
Properties="NativeVersionFile=$(MonoObjCrossDir)$(NativeVersionFile);RuntimeVersionFile=$(MonoObjCrossDir)runtime_version.h" />
</Target>

<!-- The standard set of targets that need to run before the BuildMono target runs -->
Expand Down
2 changes: 2 additions & 0 deletions src/mono/mono/mini/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,8 @@ endif()

if(HOST_WIN32)
set(mini_sources "${mini_sources};${PROJECT_BINARY_DIR}/../../NativeVersion.rc") # this is generated by GenerateMonoVersionFile in mono.proj
elseif(NOT HOST_BROWSER)
set(mini_sources "${mini_sources};${PROJECT_BINARY_DIR}/../../version.c") # this is generated by GenerateMonoVersionFile in mono.proj
endif()

set(monosgen-sources "${metadata_sources};${utils_sources};${sgen_sources};${icu_shim_sources};${mini_sources};${zlib_sources}")
Expand Down