Skip to content

Commit

Permalink
Add uninstall command; Small fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
skapix committed Aug 20, 2017
1 parent e8274db commit 6d19959
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 11 deletions.
10 changes: 9 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,15 @@ endif()


enable_testing()
install()
add_subdirectory(lib)
add_subdirectory(cohbcalc)
add_subdirectory(gohbcalc)

# uninstall target
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
IMMEDIATE @ONLY)

add_custom_target(uninstall
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
21 changes: 21 additions & 0 deletions cmake_uninstall.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
if(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
message(FATAL_ERROR "Cannot find install manifest: @CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
endif(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")

file(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files)
string(REGEX REPLACE "\n" ";" files "${files}")
foreach(file ${files})
message(STATUS "Uninstalling $ENV{DESTDIR}${file}")
if(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
exec_program(
"@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\""
OUTPUT_VARIABLE rm_out
RETURN_VALUE rm_retval
)
if(NOT "${rm_retval}" STREQUAL 0)
message(FATAL_ERROR "Problem when removing $ENV{DESTDIR}${file}")
endif(NOT "${rm_retval}" STREQUAL 0)
else(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
message(STATUS "File $ENV{DESTDIR}${file} does not exist.")
endif(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
endforeach(file)
18 changes: 15 additions & 3 deletions cohbcalc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,20 @@ cmake_minimum_required(VERSION 3.8)

project(cohbcalc)

# cxx_std_17 does not work with MSVC. Do it manually.
if (MSVC)
if (MSVC_VERSION GREATER_EQUAL "1900")
include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("/std:c++latest" cpp_latest_flag_supported)
if (cpp_latest_flag_supported)
add_compile_options("/std:c++latest")
endif()
else()
message(WARNING "Project requires c++17. Skip cohbcalc")
return()
endif()
endif(MSVC)

set(sources cohbcalc.cpp ConsoleHandler.cpp ConsoleHandler.h KeyHandler.h
../common/ExpressionHistory.cpp ../common/ExpressionHistory.h)

Expand All @@ -16,10 +30,8 @@ endif()

add_executable(cohbcalc ${sources})

target_compile_features(cohbcalc PRIVATE cxx_std_17)
set_property(TARGET cohbcalc PROPERTY CXX_STANDARD 17)

target_link_libraries(cohbcalc ohbcalc)

install(TARGETS cohbcalc DESTINATION bin)

add_custom_target(uninstall COMMAND ${CMAKE_COMMAND} -E remove ${CMAKE_INSTALL_PREFIX}/bin/cohbcalc)
6 changes: 4 additions & 2 deletions gohbcalc/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.0)

project(cohbcalc)
project(gohbcalc)

find_package(Qt5 COMPONENTS Core Widgets REQUIRED)

Expand All @@ -18,8 +18,10 @@ endif()

add_executable(gohbcalc ${GUI_EXECUTABLE} ${sources} ${resources_rcc})

set_property(TARGET cohbcalc PROPERTY CXX_STANDARD 14)
set_property(TARGET gohbcalc PROPERTY CXX_STANDARD 14)

target_include_directories(gohbcalc PRIVATE ${CMAKE_SOURCE_DIR}/common)
target_link_libraries(gohbcalc ohbcalc)
target_link_libraries(gohbcalc Qt5::Core Qt5::Widgets)

install(TARGETS gohbcalc DESTINATION bin)
13 changes: 9 additions & 4 deletions lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,20 @@ if (NOT GSL_COMPILED)
message(STATUS "GSL was successfully downloaded")
endif(NOT GSL_COMPILED)

set(public_include include/ohbTransform.h include/transformImpl/TransformImpl.h
include/ohbException.h include/ohbcalc.h)

set(sources source/OHBCalcLib.cpp source/OHBCalcImpl.cpp source/OHBCalcImpl.h
source/TokenOperation.cpp source/TokenOperation.h source/CommonDefines.h
source/CommonDefines.cpp include/ohbTransform.h include/transformImpl/TransformImpl.h
include/ohbException.h include/ohbcalc.h)
source/CommonDefines.cpp ${public_include})

add_library(ohbcalc ${sources})
target_include_directories(ohbcalc PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)
target_include_directories(ohbcalc PRIVATE ${GSL_INCLUDE_DIR})


## Testing
add_subdirectory(test)
add_subdirectory(test)

install(TARGETS ohbcalc DESTINATION lib)

install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include DESTINATION .)
2 changes: 1 addition & 1 deletion lib/include/transformImpl/TransformImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ void toBaseImpl(std::string& result, T val)
}
else
{
result.push_back('0' + val);
result.push_back('0' + static_cast<char>(val));
}
}

Expand Down

0 comments on commit 6d19959

Please sign in to comment.