summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Benjamin Barenblat <bbaren@mit.edu>2015-08-17 13:22:21 -0400
committerGravatar Benjamin Barenblat <bbaren@mit.edu>2015-08-17 13:22:21 -0400
commitdc21e4544d372a248604944cd0da14382990f0f3 (patch)
treecae6df60cd0e52668a68e6017c8c5966b7e4a4a2
parentd97efd4fb2ade6c6e9b3a3c9ba0dc870b2a025db (diff)
Switch build system to CMake
-rw-r--r--.gitignore42
-rw-r--r--CMakeLists.txt33
-rw-r--r--Makefile.am56
-rw-r--r--configure.ac46
-rw-r--r--m4/ax_cxx_compile_stdcxx_11.m4142
-rw-r--r--src/CMakeLists.txt46
6 files changed, 82 insertions, 283 deletions
diff --git a/.gitignore b/.gitignore
index ac66a6c..7e0c3f0 100644
--- a/.gitignore
+++ b/.gitignore
@@ -5,42 +5,6 @@
\#*
.\#*
-# aclocal
-aclocal.m4
-autom4te.cache/
-
-# libtoolize
-ltmain.sh
-m4/libtool.m4
-m4/ltoptions.m4
-m4/ltsugar.m4
-m4/ltversion.m4
-m4/lt~obsolete.m4
-
-# autoconf
-configure
-
-# automake
-Makefile.in
-compile
-config.guess
-config.sub
-depcomp
-install-sh
-missing
-
-# configure
-.deps/
-Makefile
-config.log
-config.status
-config.urp
-libtool
-
-# make
-.dirstamp
-*.la
-*.lo
-*.o
-
-.libs/
+# CMake
+Debug/
+Release/
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644
index 0000000..cb64d7f
--- /dev/null
+++ b/CMakeLists.txt
@@ -0,0 +1,33 @@
+# Copyright 2015 the Massachusetts Institute of Technology
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may not
+# use this file except in compliance with the License. You may obtain a copy of
+# the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations under
+# the License.
+
+cmake_policy(VERSION 3.0.2)
+cmake_minimum_required(VERSION 3.0)
+
+project(
+ urweb_crypto_hash_openssl
+ VERSION 1.0.0
+ LANGUAGES CXX
+)
+
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_FORTIFY_SOURCE=2")
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ftrapv")
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fstack-protector-strong --param=ssp-buffer-size=4")
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Weverything -Wno-c++98-compat")
+
+set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-Bsymbolic-functions")
+set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-z,relro")
+
+add_subdirectory(src)
diff --git a/Makefile.am b/Makefile.am
deleted file mode 100644
index e257a97..0000000
--- a/Makefile.am
+++ /dev/null
@@ -1,56 +0,0 @@
-# Copyright 2015 the Massachusetts Institute of Technology
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may not
-# use this file except in compliance with the License. You may obtain a copy of
-# the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations under
-# the License.
-
-ACLOCAL_AMFLAGS = -I m4
-
-CPPFLAGS = \
- -Wall \
- -D_FORTIFY_SOURCE=2 \
- @OpenSSL_CFLAGS@
-
-CXXFLAGS = \
- -std=c++11 \
- -ftrapv \
- -fstack-protector-strong --param=ssp-buffer-size=4 \
- -fPIE \
- -O2 \
- @OpenSSL_CFLAGS@
-
-CXXFLAGS += \
- -Weverything \
- -Wno-c++98-compat
-
-LDFLAGS = \
- -Wl,-Bsymbolic-functions \
- -Wl,-z,relro \
- -pie
-
-lib_LTLIBRARIES = liburweb_crypto_hash_openssl.la
-
-liburweb_crypto_hash_openssl_la_SOURCES = src/hashFFI.cc
-liburweb_crypto_hash_openssl_la_DATA = \
- src/lib.urp \
- src/hashFFI.h \
- src/hash.urs \
- src/hash.ur \
- src/hashFFI.urs
-
-liburweb_crypto_hash_openssl_la_LIBADD = @OpenSSL_LIBS@ -lurweb
-liburweb_crypto_hash_openssl_la_LDFLAGS = -export-symbols-regex '^uw_HashFFI_'
-
-liburweb_crypto_hash_openssl_ladir = $(datadir)/urweb/ur/crypto-hash-openssl
-
-EXTRA_DIST = \
- LICENSE \
- $(liburweb_crypto_hash_openssl_la_DATA)
diff --git a/configure.ac b/configure.ac
deleted file mode 100644
index 1cbdc73..0000000
--- a/configure.ac
+++ /dev/null
@@ -1,46 +0,0 @@
-# Copyright 2015 the Massachusetts Institute of Technology
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may not
-# use this file except in compliance with the License. You may obtain a copy of
-# the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations under
-# the License.
-
-AC_INIT([urweb-crypto-hash-openssl], [1.0.0], [bbaren@mit.edu])
-AM_INIT_AUTOMAKE([no-dist-gzip dist-xz foreign subdir-objects])
-LT_INIT
-
-AC_CONFIG_MACRO_DIR([m4])
-
-AC_PROG_CXX([clang++])
-AX_CXX_COMPILE_STDCXX_11([noext], [mandatory])
-
-AC_CHECK_HEADERS([openssl/md5.h openssl/sha.h],
- [],
- [AC_MSG_FAILURE([OpenSSL headers are required])])
-PKG_CHECK_MODULES([OpenSSL], [openssl])
-
-AC_CHECK_HEADERS([urweb/urweb_cpp.h],
- [],
- [AC_MSG_FAILURE([Ur/Web headers are required])])
-save_LIBS=$LIBS
-LIBS="$LIBS -lurweb"
-AC_LINK_IFELSE([AC_LANG_CALL(
- [int uw_init_client_data;
- int uw_copy_client_data;
- int uw_global_custom;
- int uw_do_expunge;
- int uw_post_expunge;
- int uw_free_client_data;],
- [uw_error])],
- [],
- [AC_MSG_FAILURE([could not link with -lurweb])])
-LIBS=$save_LIBS
-
-AC_OUTPUT([Makefile])
diff --git a/m4/ax_cxx_compile_stdcxx_11.m4 b/m4/ax_cxx_compile_stdcxx_11.m4
deleted file mode 100644
index 163a4c6..0000000
--- a/m4/ax_cxx_compile_stdcxx_11.m4
+++ /dev/null
@@ -1,142 +0,0 @@
-# ============================================================================
-# http://www.gnu.org/software/autoconf-archive/ax_cxx_compile_stdcxx_11.html
-# ============================================================================
-#
-# SYNOPSIS
-#
-# AX_CXX_COMPILE_STDCXX_11([ext|noext],[mandatory|optional])
-#
-# DESCRIPTION
-#
-# Check for baseline language coverage in the compiler for the C++11
-# standard; if necessary, add switches to CXXFLAGS to enable support.
-#
-# The first argument, if specified, indicates whether you insist on an
-# extended mode (e.g. -std=gnu++11) or a strict conformance mode (e.g.
-# -std=c++11). If neither is specified, you get whatever works, with
-# preference for an extended mode.
-#
-# The second argument, if specified 'mandatory' or if left unspecified,
-# indicates that baseline C++11 support is required and that the macro
-# should error out if no mode with that support is found. If specified
-# 'optional', then configuration proceeds regardless, after defining
-# HAVE_CXX11 if and only if a supporting mode is found.
-#
-# LICENSE
-#
-# Copyright (c) 2008 Benjamin Kosnik <bkoz@redhat.com>
-# Copyright (c) 2012 Zack Weinberg <zackw@panix.com>
-# Copyright (c) 2013 Roy Stogner <roystgnr@ices.utexas.edu>
-# Copyright (c) 2014 Alexey Sokolov <sokolov@google.com>
-#
-# Copying and distribution of this file, with or without modification, are
-# permitted in any medium without royalty provided the copyright notice
-# and this notice are preserved. This file is offered as-is, without any
-# warranty.
-
-#serial 4
-
-m4_define([_AX_CXX_COMPILE_STDCXX_11_testbody], [[
- template <typename T>
- struct check
- {
- static_assert(sizeof(int) <= sizeof(T), "not big enough");
- };
-
- struct Base {
- virtual void f() {}
- };
- struct Child : public Base {
- virtual void f() override {}
- };
-
- typedef check<check<bool>> right_angle_brackets;
-
- int a;
- decltype(a) b;
-
- typedef check<int> check_type;
- check_type c;
- check_type&& cr = static_cast<check_type&&>(c);
-
- auto d = a;
- auto l = [](){};
-]])
-
-AC_DEFUN([AX_CXX_COMPILE_STDCXX_11], [dnl
- m4_if([$1], [], [],
- [$1], [ext], [],
- [$1], [noext], [],
- [m4_fatal([invalid argument `$1' to AX_CXX_COMPILE_STDCXX_11])])dnl
- m4_if([$2], [], [ax_cxx_compile_cxx11_required=true],
- [$2], [mandatory], [ax_cxx_compile_cxx11_required=true],
- [$2], [optional], [ax_cxx_compile_cxx11_required=false],
- [m4_fatal([invalid second argument `$2' to AX_CXX_COMPILE_STDCXX_11])])
- AC_LANG_PUSH([C++])dnl
- ac_success=no
- AC_CACHE_CHECK(whether $CXX supports C++11 features by default,
- ax_cv_cxx_compile_cxx11,
- [AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_11_testbody])],
- [ax_cv_cxx_compile_cxx11=yes],
- [ax_cv_cxx_compile_cxx11=no])])
- if test x$ax_cv_cxx_compile_cxx11 = xyes; then
- ac_success=yes
- fi
-
- m4_if([$1], [noext], [], [dnl
- if test x$ac_success = xno; then
- for switch in -std=gnu++11 -std=gnu++0x; do
- cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx11_$switch])
- AC_CACHE_CHECK(whether $CXX supports C++11 features with $switch,
- $cachevar,
- [ac_save_CXXFLAGS="$CXXFLAGS"
- CXXFLAGS="$CXXFLAGS $switch"
- AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_11_testbody])],
- [eval $cachevar=yes],
- [eval $cachevar=no])
- CXXFLAGS="$ac_save_CXXFLAGS"])
- if eval test x\$$cachevar = xyes; then
- CXXFLAGS="$CXXFLAGS $switch"
- ac_success=yes
- break
- fi
- done
- fi])
-
- m4_if([$1], [ext], [], [dnl
- if test x$ac_success = xno; then
- for switch in -std=c++11 -std=c++0x; do
- cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx11_$switch])
- AC_CACHE_CHECK(whether $CXX supports C++11 features with $switch,
- $cachevar,
- [ac_save_CXXFLAGS="$CXXFLAGS"
- CXXFLAGS="$CXXFLAGS $switch"
- AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_11_testbody])],
- [eval $cachevar=yes],
- [eval $cachevar=no])
- CXXFLAGS="$ac_save_CXXFLAGS"])
- if eval test x\$$cachevar = xyes; then
- CXXFLAGS="$CXXFLAGS $switch"
- ac_success=yes
- break
- fi
- done
- fi])
- AC_LANG_POP([C++])
- if test x$ax_cxx_compile_cxx11_required = xtrue; then
- if test x$ac_success = xno; then
- AC_MSG_ERROR([*** A compiler with support for C++11 language features is required.])
- fi
- else
- if test x$ac_success = xno; then
- HAVE_CXX11=0
- AC_MSG_NOTICE([No compiler with C++11 support was found])
- else
- HAVE_CXX11=1
- AC_DEFINE(HAVE_CXX11,1,
- [define if the compiler supports basic C++11 syntax])
- fi
-
- AC_SUBST(HAVE_CXX11)
- fi
-])
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
new file mode 100644
index 0000000..32ad58b
--- /dev/null
+++ b/src/CMakeLists.txt
@@ -0,0 +1,46 @@
+# Copyright 2015 the Massachusetts Institute of Technology
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may not
+# use this file except in compliance with the License. You may obtain a copy of
+# the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations under
+# the License.
+
+add_library(urweb_crypto_hash_openssl
+ hashFFI.cc
+)
+
+set_target_properties(urweb_crypto_hash_openssl PROPERTIES
+ VERSION 0.0.0
+ SOVERSION 0
+)
+
+find_path(URWEB_INCLUDE_DIR NAMES urweb/urweb_cpp.h)
+include_directories(${URWEB_INCLUDE_DIR})
+
+find_package(OpenSSL REQUIRED)
+include_directories(${OPENSSL_INCLUDE_DIR})
+
+target_link_libraries(urweb_crypto_hash_openssl
+ ${OPENSSL_CRYPTO_LIBRARY}
+)
+
+install(TARGETS urweb_crypto_hash_openssl
+ ARCHIVE DESTINATION lib
+ LIBRARY DESTINATION lib
+)
+install(
+ FILES
+ hashFFI.h
+ hashFFI.urs
+ hash.ur
+ hash.urs
+ lib.urp
+ DESTINATION share/urweb/ur/crypto-hash-openssl
+)