Commit 7cd8f0eb by Sachin Basil John

cleaner, more organized file

parent 83de7e3e
#CMakeLists for using EMBB as an external library in a project. #CMakelists for using EMBB as an external library in a project
project (EMBB_USER_PROJECT) project (EMBB_USER_PROJECT)
set(EXECUTABLE_NAME exec) set(EXECUTABLE_NAME exec)
set(BUILD_STATIC 1)
cmake_minimum_required (VERSION 2.8.9) cmake_minimum_required (VERSION 2.8.9)
# Version number # Version number
...@@ -11,18 +8,31 @@ set (EMBB_USER_PROJECT_BASE_VERSION_MAJOR 0) ...@@ -11,18 +8,31 @@ set (EMBB_USER_PROJECT_BASE_VERSION_MAJOR 0)
set (EMBB_USER_PROJECT_BASE_VERSION_MINOR 0) set (EMBB_USER_PROJECT_BASE_VERSION_MINOR 0)
set (EMBB_USER_PROJECT_BASE_VERSION_PATCH 1) set (EMBB_USER_PROJECT_BASE_VERSION_PATCH 1)
#############################################
# Make a browsable file hierarchy when opening
# the generated visual c++ solution project in visual studio
function(GroupSourcesMSVC directory)
file(GLOB children RELATIVE ${PROJECT_SOURCE_DIR}/${directory} ${PROJECT_SOURCE_DIR}/${directory}/*)
foreach(child ${children})
if(IS_DIRECTORY ${PROJECT_SOURCE_DIR}/${directory}/${child})
GroupSourcesMSVC(${directory}/${child})
else()
string(REPLACE "/" "\\" groupname ${directory})
string(REPLACE "src" "Sources" groupname ${groupname})
string(REPLACE "include" "Includes" groupname ${groupname})
source_group(${groupname} FILES ${PROJECT_SOURCE_DIR}/${directory}/${child})
endif()
endforeach()
endfunction()
####################
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
if(BUILD_STATIC)
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd")
else()
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd")
endif()
set(INT_DIR "/${CMAKE_CFG_INTDIR}/") set(INT_DIR "/${CMAKE_CFG_INTDIR}/")
set(ADDITIONAL_LIBS "") set(ADDITIONAL_LIBS "")
GroupSourcesMSVC(src)
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" ) elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" )
set(INT_DIR "/") set(INT_DIR "/")
set(ADDITIONAL_LIBS "pthread" "rt") set(ADDITIONAL_LIBS "pthread" "rt")
else() else()
...@@ -38,20 +48,21 @@ ExternalProject_Add(EMBB ...@@ -38,20 +48,21 @@ ExternalProject_Add(EMBB
INSTALL_COMMAND "" INSTALL_COMMAND ""
) )
ExternalProject_Get_Property(EMBB source_dir) ExternalProject_Get_Property(EMBB source_dir)
ExternalProject_Get_Property(EMBB binary_dir) ExternalProject_Get_Property(EMBB binary_dir)
set(EMBB_BINARY_DIR ${binary_dir}) set(EMBB_BINARY_DIR ${binary_dir})
set(EMBB_SOURCE_DIR ${source_dir}) set(EMBB_SOURCE_DIR ${source_dir})
set(EMBB_DIRS containers_cpp algorithms_cpp dataflow_cpp tasks_cpp mtapi_cpp base_cpp mtapi_c base_c) set(EMBB_DIRS containers_cpp algorithms_cpp dataflow_cpp tasks_cpp mtapi_cpp base_cpp mtapi_c base_c) #link order matters for GNU compiler
set(EMBB_GENERATED_INCLUDE base_c base_cpp tasks_cpp) set(EMBB_GENERATED_INCLUDE base_c base_cpp tasks_cpp) # modules with cmake generated header files
### end external project ### end external project
set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/) set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/)
#Find other modules if any
####################################################
file(GLOB_RECURSE EMBB_USER_PROJECT_SOURCES "src/*.cpp" "src/*.h") file(GLOB_RECURSE EMBB_USER_PROJECT_SOURCES "src/*.cpp" "src/*.h")
file(GLOB_RECURSE EMBB_USER_PROJECT_HEADERS "src/*.h") file(GLOB_RECURSE EMBB_USER_PROJECT_HEADERS "src/*.h")
...@@ -59,39 +70,10 @@ file(GLOB_RECURSE EMBB_USER_PROJECT_HEADERS "src/*.h") ...@@ -59,39 +70,10 @@ file(GLOB_RECURSE EMBB_USER_PROJECT_HEADERS "src/*.h")
add_executable(${EXECUTABLE_NAME} ${EMBB_USER_PROJECT_SOURCES} ${EMBB_USER_PROJECT_HEADERS}) add_executable(${EXECUTABLE_NAME} ${EMBB_USER_PROJECT_SOURCES} ${EMBB_USER_PROJECT_HEADERS})
add_dependencies(${EXECUTABLE_NAME} EMBB) add_dependencies(${EXECUTABLE_NAME} EMBB)
############################################# ######################################
set(pref ${CMAKE_STATIC_LIBRARY_PREFIX}embb_)
# Make a browsable file hierarchy when opening in IDE set(suf ${CMAKE_STATIC_LIBRARY_SUFFIX})
function(GroupSources directory)
file(GLOB children RELATIVE ${PROJECT_SOURCE_DIR}/${directory} ${PROJECT_SOURCE_DIR}/${directory}/*)
foreach(child ${children})
if(IS_DIRECTORY ${PROJECT_SOURCE_DIR}/${directory}/${child})
GroupSources(${directory}/${child})
else()
if(WIN32)
string(REPLACE "/" "\\" groupname ${directory})
endif()
string(REPLACE "src" "Sources" groupname ${groupname})
string(REPLACE "include" "Includes" groupname ${groupname})
source_group(${groupname} FILES ${PROJECT_SOURCE_DIR}/${directory}/${child})
endif()
endforeach()
endfunction()
GroupSources(src)
####################################################
if(BUILD_STATIC)
set(pref ${CMAKE_STATIC_LIBRARY_PREFIX})
set(suf ${CMAKE_STATIC_LIBRARY_SUFFIX})
else()
set(pref ${CMAKE_SHARED_LIBRARY_PREFIX})
set(suf ${CMAKE_SHARED_LIBRARY_SUFFIX})
endif()
###########################################
foreach(dir ${EMBB_DIRS}) foreach(dir ${EMBB_DIRS})
include_directories ("${EMBB_SOURCE_DIR}/${dir}/include") include_directories ("${EMBB_SOURCE_DIR}/${dir}/include")
list(APPEND LIBS "${EMBB_BINARY_DIR}/${dir}${INT_DIR}${pref}${dir}${suf}") list(APPEND LIBS "${EMBB_BINARY_DIR}/${dir}${INT_DIR}${pref}${dir}${suf}")
...@@ -100,4 +82,7 @@ endforeach() ...@@ -100,4 +82,7 @@ endforeach()
foreach(dir ${EMBB_GENERATED_INCLUDE}) foreach(dir ${EMBB_GENERATED_INCLUDE})
include_directories("${EMBB_BINARY_DIR}/${dir}/include") include_directories("${EMBB_BINARY_DIR}/${dir}/include")
endforeach() endforeach()
target_link_libraries( ${EXECUTABLE_NAME} ${LIBS} ${ADDITIONAL_LIBS} ) target_link_libraries( ${EXECUTABLE_NAME} ${LIBS} ${ADDITIONAL_LIBS} )
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment