Skip to content

Commit

Permalink
Now this almost builds on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
Dmitry Panteleev committed Aug 3, 2014
1 parent 6575789 commit 35da7bd
Show file tree
Hide file tree
Showing 39 changed files with 4,005 additions and 167 deletions.
62 changes: 54 additions & 8 deletions 3rdParty/gmp/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Specify the version being used aswell as the language
cmake_minimum_required(VERSION 3.0.0)
cmake_policy(VERSION 3.0.0)
cmake_minimum_required(VERSION 2.8.12)
cmake_policy(VERSION 2.8.12)

include(ExternalProject)

Expand Down Expand Up @@ -46,22 +46,25 @@ elseif(MSVC)
URL http://www.mpir.org/mpir-2.6.0.tar.bz2
URL_HASH MD5=81be2f605330d030956c1ff515c58564
SOURCE_DIR "src/mpir"
# PATCH_COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/3rd-party/mpir_zero_patched.c <SOURCE_DIR>/mpn/generic/zero.c
PATCH_COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/mpir_zero_patched.c <SOURCE_DIR>/mpn/generic/zero.c
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/mpirxx_patched.h <SOURCE_DIR>/mpirxx.h
CONFIGURE_COMMAND ""
BUILD_IN_SOURCE 1
BUILD_COMMAND ${CMAKE_COMMAND} -E chdir "<SOURCE_DIR>/build.vc10" ${CMAKE_MAKE_PROGRAM} lib_mpir_gc\\lib_mpir_gc.vcxproj /p:configuration=Debug /p:platform=x64 /p:SolutionDir="<SOURCE_DIR>\\build.vc10\\\\" /p:PlatformToolset=v120
BUILD_COMMAND ${CMAKE_COMMAND} -E chdir "<SOURCE_DIR>/build.vc10" ${CMAKE_MAKE_PROGRAM} lib_mpir_gc\\lib_mpir_gc.vcxproj /p:configuration=Debug /p:platform=x64 /p:SolutionDir=<SOURCE_DIR>\\build.vc10\\\\ /p:PlatformToolset=v120
INSTALL_DIR "mpir"
INSTALL_COMMAND ${CMAKE_COMMAND} -E copy "<SOURCE_DIR>/lib/x64/Debug/gmp.h" "<INSTALL_DIR>/include/gmp.h"
COMMAND ${CMAKE_COMMAND} -E copy_directory "<SOURCE_DIR>/lib/x64/Debug" "<INSTALL_DIR>/lib/x64/Debug"
COMMAND ${CMAKE_COMMAND} -E copy "<SOURCE_DIR>/lib/x64/Debug/mpir.lib" "<INSTALL_DIR>/lib/mpir-debug.lib"
COMMAND ${CMAKE_COMMAND} -E copy "<SOURCE_DIR>/lib/x64/Debug/mpir.pdb" "<INSTALL_DIR>/lib/mpir.pdb"
COMMAND ${CMAKE_COMMAND} -E copy "<SOURCE_DIR>/lib/x64/Debug/mpir.pdb" "<INSTALL_DIR>/lib/mpir-debug.pdb"
)

add_library(gmp STATIC IMPORTED GLOBAL)
add_library(gmpxx STATIC IMPORTED GLOBAL)
ExternalProject_Get_Property(mpir-debug install_dir)

file(MAKE_DIRECTORY "${install_dir}/include")

ExternalProject_Get_Property(mpir-debug install_dir)
set_target_properties(libgmp PROPERTIES
set_target_properties(gmp PROPERTIES
IMPORTED_CONFIGURATIONS "Debug;Release"
IMPORTED_LOCATION_DEBUG "${install_dir}/lib/mpir-debug.lib"
INTERFACE_INCLUDE_DIRECTORIES "${install_dir}/include"
Expand All @@ -78,9 +81,11 @@ elseif(MSVC)
SOURCE_DIR "src/mpir"
CONFIGURE_COMMAND ""
BUILD_IN_SOURCE 1
BUILD_COMMAND ${CMAKE_COMMAND} -E chdir "<SOURCE_DIR>/build.vc10" ${CMAKE_MAKE_PROGRAM} lib_mpir_gc\\lib_mpir_gc.vcxproj /p:configuration=Release /p:platform=x64 /p:SolutionDir="<SOURCE_DIR>\\build.vc10\\\\" /p:PlatformToolset=v120
BUILD_COMMAND ${CMAKE_COMMAND} -E chdir "<SOURCE_DIR>/build.vc10" ${CMAKE_MAKE_PROGRAM} lib_mpir_gc\\lib_mpir_gc.vcxproj /p:configuration=Release /p:platform=x64 /p:SolutionDir=<SOURCE_DIR>\\build.vc10\\\\ /p:PlatformToolset=v120
INSTALL_DIR "mpir"
INSTALL_COMMAND ${CMAKE_COMMAND} -E copy "<SOURCE_DIR>/lib/x64/Release/gmp.h" "<INSTALL_DIR>/include/gmp.h"
COMMAND ${CMAKE_COMMAND} -E copy "<SOURCE_DIR>/lib/x64/Release/mpir.h" "<INSTALL_DIR>/include/mpir.h"
COMMAND ${CMAKE_COMMAND} -E copy "<SOURCE_DIR>/lib/x64/Release/gmpxx.h" "<INSTALL_DIR>/include/gmpxx.h"
COMMAND ${CMAKE_COMMAND} -E copy_directory "<SOURCE_DIR>/lib/x64/Release" "<INSTALL_DIR>/lib/x64/Release"
COMMAND ${CMAKE_COMMAND} -E copy "<SOURCE_DIR>/lib/x64/Release/mpir.lib" "<INSTALL_DIR>/lib/mpir-release.lib"
COMMAND ${CMAKE_COMMAND} -E copy "<SOURCE_DIR>/lib/x64/Release/mpir.pdb" "<INSTALL_DIR>/lib/mpir-release.pdb"
Expand All @@ -92,6 +97,47 @@ elseif(MSVC)
)

add_dependencies(gmp mpir-release)

ExternalProject_Add(mpirxx-debug
PREFIX mpir
DEPENDS mpir-debug
DOWNLOAD_COMMAND ""
SOURCE_DIR "src/mpir"
CONFIGURE_COMMAND ""
BUILD_IN_SOURCE 1
BUILD_COMMAND ${CMAKE_COMMAND} -E chdir "<SOURCE_DIR>/build.vc10" ${CMAKE_MAKE_PROGRAM} lib_mpir_cxx\\lib_mpir_cxx.vcxproj /p:configuration=Debug /p:platform=x64 /p:SolutionDir=<SOURCE_DIR>\\build.vc10\\\\ /p:PlatformToolset=v120
INSTALL_DIR "mpir"
INSTALL_COMMAND ${CMAKE_COMMAND} -E copy "<SOURCE_DIR>/lib/x64/Debug/gmpxx.h" "<INSTALL_DIR>/include/gmpxx.h"
COMMAND ${CMAKE_COMMAND} -E copy_directory "<SOURCE_DIR>/lib/x64/Debug" "<INSTALL_DIR>/lib/x64/Debug"
COMMAND ${CMAKE_COMMAND} -E copy "<SOURCE_DIR>/lib/x64/Debug/mpirxx.lib" "<INSTALL_DIR>/lib/mpirxx-debug.lib"
COMMAND ${CMAKE_COMMAND} -E copy "<SOURCE_DIR>/lib/x64/Debug/mpirxx.pdb" "<INSTALL_DIR>/lib/mpirxx-debug.pdb"
)

ExternalProject_Add(mpirxx-release
PREFIX mpir
DEPENDS mpir-debug
DOWNLOAD_COMMAND ""
SOURCE_DIR "src/mpir"
CONFIGURE_COMMAND ""
BUILD_IN_SOURCE 1
BUILD_COMMAND ${CMAKE_COMMAND} -E chdir "<SOURCE_DIR>/build.vc10" ${CMAKE_MAKE_PROGRAM} lib_mpir_cxx\\lib_mpir_cxx.vcxproj /p:configuration=Release /p:platform=x64 /p:SolutionDir=<SOURCE_DIR>\\build.vc10\\\\ /p:PlatformToolset=v120
INSTALL_DIR "mpir"
INSTALL_COMMAND ${CMAKE_COMMAND} -E copy "<SOURCE_DIR>/lib/x64/Release/gmpxx.h" "<INSTALL_DIR>/include/gmpxx.h"
COMMAND ${CMAKE_COMMAND} -E copy_directory "<SOURCE_DIR>/lib/x64/Release" "<INSTALL_DIR>/lib/x64/Release"
COMMAND ${CMAKE_COMMAND} -E copy "<SOURCE_DIR>/lib/x64/Release/mpirxx.lib" "<INSTALL_DIR>/lib/mpirxx-release.lib"
COMMAND ${CMAKE_COMMAND} -E copy "<SOURCE_DIR>/lib/x64/Release/mpirxx.pdb" "<INSTALL_DIR>/lib/mpirxx-release.pdb"
)


set_target_properties(gmpxx PROPERTIES
IMPORTED_CONFIGURATIONS "Debug;Release"
INTERFACE_INCLUDE_DIRECTORIES "${install_dir}/include"
IMPORTED_LOCATION_DEBUG "${install_dir}/lib/mpirxx-debug.lib"
IMPORTED_LOCATION_RELEASE "${install_dir}/lib/mpirxx-release.lib"
)

add_dependencies(gmpxx mpirxx-debug mpirxx-release)


ELSE()
message( FATAL_ERROR "You should use UNIX or MSVC" )
Expand Down
31 changes: 31 additions & 0 deletions 3rdParty/gmp/mpir_zero_patched.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/* mpn_zero
Copyright 2009 Free Software Foundation, Inc.
This file is part of the GNU MP Library.
The GNU MP Library is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 3 of the License, or (at your
option) any later version.
The GNU MP Library is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */

#include "mpir.h"
#include "gmp-impl.h"

void mpn_zero (mp_ptr rp, mp_size_t n)
{
mp_size_t i;

//rp += n;
for (i = 0; i < n; i++) {
rp[i] = 0;
}
}
Loading

0 comments on commit 35da7bd

Please sign in to comment.