Add cmake scripts for example compilation
authorKrzysztof Jackiewicz <k.jackiewicz@samsung.com>
Mon, 4 Apr 2016 09:09:29 +0000 (11:09 +0200)
committerMateusz Kulikowski <m.kulikowski@samsung.com>
Thu, 7 Apr 2016 09:23:31 +0000 (11:23 +0200)
Change-Id: I0eaf20b6e20bf0285e50b066572d53cc93074efe

CMakeLists.txt
examples/CMakeLists.txt [new file with mode: 0644]
examples/Makefile [deleted file]

index 66c9c73..bf760cd 100644 (file)
@@ -86,4 +86,4 @@ ENDIF(NOT DEFINED INCLUDE_INSTALL_DIR)
 
 ADD_SUBDIRECTORY(${SRC_FOLDER})
 #ADD_SUBDIRECTORY(${TEST_FOLDER})
-#ADD_SUBDIRECTORY(${EXAMPLES_FOLDER})
+ADD_SUBDIRECTORY(${EXAMPLES_FOLDER})
diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt
new file mode 100644 (file)
index 0000000..bcaa955
--- /dev/null
@@ -0,0 +1,55 @@
+#
+#  Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+#
+#  Contact:
+#
+#  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
+#
+#
+# @file   CMakeLists.txt
+# @author Krzysztof Jackiewicz (k.jackiewicz@samsung.com)
+# @version 1.0
+# @brief
+#
+
+INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/api)
+
+SET(COMMON_SOURCES
+                ${CMAKE_CURRENT_SOURCE_DIR}/lorem.c
+                ${CMAKE_CURRENT_SOURCE_DIR}/misc.c
+    )
+
+FUNCTION(BUILD_EXAMPLE EXAMPLE_NAME SOURCE_FILE)
+    ADD_EXECUTABLE(${EXAMPLE_NAME}
+                    ${CMAKE_CURRENT_SOURCE_DIR}/${SOURCE_FILE}
+                    ${COMMON_SOURCES}
+        )
+    TARGET_LINK_LIBRARIES(${EXAMPLE_NAME} ${PROJECT_NAME})
+    INSTALL(TARGETS ${EXAMPLE_NAME}
+        DESTINATION /usr/bin
+        PERMISSIONS OWNER_READ
+                    OWNER_WRITE
+                    OWNER_EXECUTE
+                    GROUP_READ
+                    GROUP_EXECUTE
+                    WORLD_READ
+                    WORLD_EXECUTE
+        )
+ENDFUNCTION(BUILD_EXAMPLE)
+
+BUILD_EXAMPLE("owl-example-digest"       digest.c)
+BUILD_EXAMPLE("owl-example-encrypt"      encrypt.c)
+BUILD_EXAMPLE("owl-example-encrypt-gcm"  encrypt_aes_gcm.c)
+BUILD_EXAMPLE("owl-example-sign"         sign.c)
+BUILD_EXAMPLE("owl-example-key-exchange" key_exchange.c)
+BUILD_EXAMPLE("owl-example-test"         test.c)
\ No newline at end of file
diff --git a/examples/Makefile b/examples/Makefile
deleted file mode 100644 (file)
index b1c828a..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-# Sample makefile - for now it only checks if sources compile
-
-# Disable implicit rules
-.SUFFIXES:
-
-# keep objects
-.PRECIOUS: %.o
-
-examples := digest.c encrypt.c encrypt_aes_gcm.c key_exchange.c sign.c test.c
-
-bins := $(basename $(examples))
-objs := $(addsuffix .o, $(bins))
-deps := $(addsuffix .d, $(bins))
-
-common-objs := misc.o lorem.o
-common-deps := misc.d lorem.d
-
-LDFLAGS :=  -L../src
-LIBS:= -lCryptoAPI $(shell pkg-config --libs openssl)
-CFLAGS := $(shell pkg-config --cflags openssl) -I../api -Wall -MMD
-
-all: build
-
-build: $(bins)
-
-%: %.o $(common-objs)
-       gcc $(CFLAGS) $(LDFLAGS) $^ $(LIBS)  -o $@
-
-clean:
-       rm -f $(objs) $(deps) $(bins) $(common-objs) $(common-deps)
-
-
-%.o: %.c
-       gcc $(CFLAGS) -c $< -o $@
-
--include $(deps)