CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
-#SET(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS true)
PROJECT(app2ext C)
-SET(VERSION_MAJOR 0)
-SET(VERSION "${VERSION_MAJOR}.4.2")
+SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden")
+SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -g -Wall -Werror")
-#Add your submodule directory name
-ADD_SUBDIRECTORY(plugin/app2sd)
-
-### Required packages
INCLUDE(FindPkgConfig)
-pkg_check_modules(pkgs REQUIRED dlog)
-
-FOREACH(flag ${pkgs_CFLAGS})
- SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
-ENDFOREACH(flag)
-
-pkg_check_modules(libpkgs REQUIRED dlog)
+pkg_check_modules(app2ext_libpkgs REQUIRED dlog glib-2.0)
-FOREACH(flag ${libpkgs_CFLAGS})
- SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+FOREACH(flag ${app2ext_libpkgs_CFLAGS})
+ SET(APP2EXT_CFLAGS "${APP2EXT_CFLAGS} ${flag}")
ENDFOREACH(flag)
+SET(CMAKE_C_FLAGS "${EXTRA_CFLAGS} ${APP2EXT_CFLAGS}")
-SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
+ADD_DEFINITIONS("-DLIBPREFIX=\"${LIB_INSTALL_DIR}\"")
-### Local include directories
-INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/inc
- ${CMAKE_SOURCE_DIR}/common/inc)
+# Local include directories
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/inc)
-## build app2ext library
-SET(app2ext_dir "${CMAKE_SOURCE_DIR}")
-SET(app2ext_src_dir "${app2ext_dir}/src")
+# build app2ext library
SET(APP2EXT "app2ext")
-SET(libapp2ext_SOURCES
- ${app2ext_src_dir}/app2ext_interface.c
- ${CMAKE_SOURCE_DIR}/common/src/app2ext_utils.c)
-SET(libapp2ext_LDFLAGS " -L${LIB_INSTALL_DIR} -module -avoid-version -ldl ")
-SET(libapp2ext_CFLAGS " ${CFLAGS} -fPIC ")
+AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/src APP2EXT_SRCS)
-ADD_DEFINITIONS("-DLIBPREFIX=\"${LIB_INSTALL_DIR}\"")
-
-ADD_LIBRARY(${APP2EXT} SHARED ${libapp2ext_SOURCES})
-SET_TARGET_PROPERTIES(${APP2EXT} PROPERTIES SOVERSION ${VERSION_MAJOR})
-SET_TARGET_PROPERTIES(${APP2EXT} PROPERTIES VERSION ${VERSION})
-SET_TARGET_PROPERTIES(${APP2EXT} PROPERTIES COMPILE_FLAGS "${libapp2ext_CFLAGS}")
-TARGET_LINK_LIBRARIES(${APP2EXT} ${libpkgs_LDFLAGS})
-
-SET(CMAKE_INSTALL_PREFIX "/usr")
-SET(PREFIX ${CMAKE_INSTALL_PREFIX})
+ADD_LIBRARY(${APP2EXT} SHARED ${APP2EXT_SRCS})
+SET_TARGET_PROPERTIES(${APP2EXT} PROPERTIES SOVERSION ${MAJORVER})
+SET_TARGET_PROPERTIES(${APP2EXT} PROPERTIES VERSION ${FULLVER})
+SET_TARGET_PROPERTIES(${APP2EXT} PROPERTIES COMPILE_FLAGS ${CFLAGS} "-fPIC -fstack-protector-strong")
+SET_TARGET_PROPERTIES(${APP2EXT} PROPERTIES LINK_FLAGS "-Wl,--as-needed,-z,relro")
+TARGET_LINK_LIBRARIES(${APP2EXT} ${app2ext_libpkgs_LDFLAGS})
CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/app2sd.manifest.in ${CMAKE_BINARY_DIR}/app2sd.manifest @ONLY)
-
CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/app2sd.pc.in ${CMAKE_BINARY_DIR}/app2sd.pc @ONLY)
INSTALL(TARGETS ${APP2EXT} DESTINATION ${LIB_INSTALL_DIR} COMPONENT RuntimeLibraries)
INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/app2sd.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
-INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/inc/app2ext_interface.h DESTINATION include)
+INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/inc/ DESTINATION include)
+ADD_SUBDIRECTORY(plugin/app2sd)
ADD_SUBDIRECTORY(test)
-