Skip to content

Commit

Permalink
Place binary output files in directories
Browse files Browse the repository at this point in the history
  • Loading branch information
tigertv committed Dec 8, 2020
1 parent e857bc4 commit 2f867ee
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,31 @@ else()
add_compile_options(-Wall -Wextra -pedantic)
endif()

# sources
include_directories(include)
aux_source_directory(src/Bint BINT_SRC)
set(BINT_SRC ${BINT_SRC} src/Bint.cpp)
set(MATH_SRC src/Math.cpp)
add_library(shareobjects OBJECT ${BINT_SRC} ${MATH_SRC})

# libraries
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})

add_library(Bint SHARED ${BINT_SRC} ${MATH_SRC})
add_library(Bint_static STATIC $<TARGET_OBJECTS:shareobjects>)
set_target_properties(Bint_static PROPERTIES OUTPUT_NAME Bint)

# tests
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/tests")

add_executable(test-main-fast tests/main.cpp ${BINT_SRC} ${MATH_SRC})
set_target_properties(test-main-fast PROPERTIES COMPILE_FLAGS -Ofast)
add_test(NAME tst-main-fast COMMAND ./test-main-fast)
add_test(NAME tst-main-fast COMMAND ./tests/test-main-fast)

aux_source_directory(tests TESTS)
foreach(tstfile ${TESTS})
string(REGEX MATCH "\/(.*)\\.[^.]*$" dummy ${tstfile})
add_executable(test-${CMAKE_MATCH_1} ${tstfile} $<TARGET_OBJECTS:shareobjects>)
add_test(NAME tst-${CMAKE_MATCH_1} COMMAND ./test-${CMAKE_MATCH_1})
add_test(NAME tst-${CMAKE_MATCH_1} COMMAND ./tests/test-${CMAKE_MATCH_1})
endforeach()

add_library(Bint SHARED ${BINT_SRC} ${MATH_SRC})
add_library(Bint_static STATIC $<TARGET_OBJECTS:shareobjects>)
set_target_properties(Bint_static PROPERTIES OUTPUT_NAME Bint)

0 comments on commit 2f867ee

Please sign in to comment.