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

CMake portability improvements #686

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
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
35 changes: 31 additions & 4 deletions cpp_version/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
cmake_minimum_required(VERSION 3.1)
cmake_minimum_required(VERSION 3.5)
project(ranger)
include (GNUInstallDirs)

## ======================================================================================##
## Check for C++14
Expand All @@ -10,7 +11,11 @@ set (CMAKE_CXX_STANDARD_REQUIRED TRUE)
## ======================================================================================##
## Compiler flags
## ======================================================================================##
add_compile_options(-Wall)
include (CheckCXXCompilerFlag)
check_cxx_compiler_flag ("-Wall" COMPILER_SUPPORTS_WALL)
if (COMPILER_SUPPORTS_WALL)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
endif ()

## ======================================================================================##
## Threads
Expand Down Expand Up @@ -43,10 +48,32 @@ ADD_CUSTOM_TARGET(release
)

## ======================================================================================##
## Executable
## Library
## ======================================================================================##
add_executable(ranger ${SOURCES})
file(GLOB_RECURSE SOURCES src/utility/*.cpp src/Forest/*.cpp src/Tree/*.cpp)
if (MSVC)
list(APPEND SOURCES src/getopt/getopt.c)
endif ()
option(BUILD_SHARED_LIBS "shared/static lib" OFF)
add_library(ranger ${SOURCES})
target_include_directories(ranger PUBLIC src/utility src/Forest src/Tree src)
if (MSVC)
target_include_directories(ranger PRIVATE src/getopt)
endif ()
target_link_libraries(ranger Threads::Threads)
install(TARGETS ranger RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
file(GLOB_RECURSE HEADERS src/*.h)
install (FILES ${HEADERS} DESTINATION include/ranger)

## ======================================================================================##
## Executable
## ======================================================================================##
add_executable(ranger-cli src/main.cpp)
set_target_properties(ranger-cli PROPERTIES OUTPUT_NAME ranger)
target_link_libraries(ranger-cli ranger)
install(TARGETS ranger-cli DESTINATION ${CMAKE_INSTALL_BINDIR})

## ======================================================================================##
## Test
Expand Down
Loading
Loading