Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow cmake to build as both a standalone project as well as a subproject (ie add_subdirectory(mkl-dnn)) #44

Merged
merged 3 commits into from
Apr 13, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,21 @@
#===============================================================================

set(TARGET_NAME ${LIB_NAME})

file(GLOB_RECURSE HEADERS
${CMAKE_SOURCE_DIR}/include/*.h
${CMAKE_SOURCE_DIR}/include/*.hpp
${CMAKE_CURRENT_SOURCE_DIR}/../include/*.h
${CMAKE_CURRENT_SOURCE_DIR}/../include/*.hpp
)
file(GLOB_RECURSE SOURCES
${CMAKE_SOURCE_DIR}/src/*.c
${CMAKE_SOURCE_DIR}/src/*.cpp
${CMAKE_SOURCE_DIR}/src/*.h
${CMAKE_SOURCE_DIR}/src/*.hpp
${CMAKE_CURRENT_SOURCE_DIR}/*.c
${CMAKE_CURRENT_SOURCE_DIR}/*.cpp
${CMAKE_CURRENT_SOURCE_DIR}/*.h
${CMAKE_CURRENT_SOURCE_DIR}/*.hpp
)
include_directories(
${CMAKE_SOURCE_DIR}/src
${CMAKE_SOURCE_DIR}/src/common
${CMAKE_SOURCE_DIR}/src/cpu/xbyak
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/common
${CMAKE_CURRENT_SOURCE_DIR}/cpu/xbyak
)
add_library(${TARGET_NAME} SHARED ${HEADERS} ${SOURCES})
target_link_libraries(${TARGET_NAME} ${${TARGET_NAME}_LINKER_LIBS})
Expand Down
4 changes: 1 addition & 3 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ if(POLICY CMP0065)
cmake_policy(SET CMP0065 NEW)
endif()

include_directories(${CMAKE_SOURCE_DIR}/include)

#add_executable(api-check-c api_check.c)
#target_link_libraries(api-check-c ${LIB_NAME})
#add_test(api-check-c api-check-c)
Expand All @@ -39,7 +37,7 @@ add_executable(test_c_symbols-c ${test_c_symbols})
add_custom_command(
OUTPUT ${test_c_symbols}
COMMAND /bin/bash ${CMAKE_CURRENT_SOURCE_DIR}/generate_c_symbols_refs.sh
${CMAKE_SOURCE_DIR} ${test_c_symbols}
${CMAKE_CURRENT_SOURCE_DIR}/.. ${test_c_symbols}
)
target_link_libraries(test_c_symbols-c ${LIB_NAME})

Expand Down
12 changes: 6 additions & 6 deletions tests/gtests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ add_subdirectory (gtest)

set(APP_NAME "gtest")
set(MAIN_SRC_GTEST main.cpp)
include_directories(${CMAKE_SOURCE_DIR}/include)
include_directories(${CMAKE_SOURCE_DIR}/tests/gtests
${CMAKE_SOURCE_DIR}/tests/gtests/gtest

include_directories(${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/gtest
${CMAKE_CURRENT_SOURCE_DIR}/in
)
include_directories(${CMAKE_SOURCE_DIR}/tests/gtests/in)
# TODO: enable me!
#file(GLOB API_TEST_CASES_SRC api_tests/*.cpp)
#file(GLOB PRIM_TEST_CASES_SRC test_*.cpp)
file(GLOB PRIM_TEST_CASES_SRC RELATIVE ${CMAKE_SOURCE_DIR}/tests/gtests
file(GLOB PRIM_TEST_CASES_SRC
test_sum.cpp
test_reorder.cpp
test_concat.cpp
Expand All @@ -51,7 +51,7 @@ foreach(TEST_FILE ${PRIM_TEST_CASES_SRC})
get_filename_component (TEST_FILE_WE ${TEST_FILE} NAME_WE)
set(CURR_APP_NAME ${TEST_FILE_WE})
add_executable(${CURR_APP_NAME} ${MAIN_SRC_GTEST} ${TEST_FILE})
target_link_libraries(${CURR_APP_NAME} mkldnn gtest)
target_link_libraries(${CURR_APP_NAME} mkldnn mkldnn_gtest)
add_test(${CURR_APP_NAME} ${CURR_APP_NAME})
endforeach()

Expand Down
7 changes: 4 additions & 3 deletions tests/gtests/gtest/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
# Do not modify this file

set(TARGET_NAME gtest)
set(TARGET_NAME mkldnn_gtest)
set(MAIN_SRC "src/gtest-all.cc")
source_group("" FILES ${MAIN_SRC})
include_directories(${CMAKE_SOURCE_DIR}/tests/gtests
${CMAKE_SOURCE_DIR}/tests/gtests/gtest)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/..
)
find_package(Threads REQUIRED)
add_library(${TARGET_NAME} STATIC ${MAIN_SRC})
target_link_libraries(${TARGET_NAME} ${CMAKE_THREAD_LIBS_INIT})