Use JAVA_HOME to find Java on macOS.
Install files into CMAKE_INSTALL_PREFIX not /usr.
Treat MacPorts build type as Release.
Don't force -stdlib=libc++ on macOS. MacPorts will set the right lib to use.
--- CMakeLists.txt.orig 2018-01-11 11:18:20.000000000 -0600
+++ CMakeLists.txt 2018-11-12 17:13:35.000000000 -0600
# and the Java Development Kit 'include' directories added
set(BUILD_SHARED_LIBS ON)
set(java_home $ENV{JAVA_HOME})
message(FATAL_ERROR "Environment variable JAVA_HOME not defined")
if(BUILD_SHARED_LIBS OR BUILD_STATIC_LIBS)
add_library(astyle ${SRCS})
- install(TARGETS astyle DESTINATION /usr/lib)
+ install(TARGETS astyle DESTINATION lib)
add_executable(astyle ${SRCS})
install(TARGETS astyle DESTINATION ${prog_files}/AStyle)
install(FILES ${DOCS} DESTINATION ${prog_files}/AStyle/doc/)
- install(TARGETS astyle DESTINATION /usr/bin)
- install(FILES ${DOCS} DESTINATION /usr/share/doc/astyle)
+ install(TARGETS astyle DESTINATION bin)
+ install(FILES ${DOCS} DESTINATION share/doc/astyle)
target_include_directories(astyle PRIVATE $ENV{JAVA_HOME}/include)
target_include_directories(astyle PRIVATE $ENV{JAVA_HOME}/include/win32)
+ target_include_directories(astyle PRIVATE $ENV{JAVA_HOME}/include)
+ target_include_directories(astyle PRIVATE $ENV{JAVA_HOME}/include/darwin)
target_include_directories(astyle PRIVATE /usr/lib/jvm/default-java/include)
target_include_directories(astyle PRIVATE /usr/lib/jvm/default-java/include/linux)
macro(set_linker_options strip_option)
# Remove -rdynamic and add 'strip' to linker flags
- if(CMAKE_BUILD_TYPE STREQUAL "Release" OR CMAKE_BUILD_TYPE STREQUAL "MinSizeRel")
+ if(CMAKE_BUILD_TYPE STREQUAL "Release" OR CMAKE_BUILD_TYPE STREQUAL "MinSizeRel" OR CMAKE_BUILD_TYPE STREQUAL "MacPorts")
set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${strip_option}")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${strip_option}")
# Set default compile options for supported compilers
- astyle PRIVATE -W -Wall -fno-rtti -fno-exceptions -std=c++11 -stdlib=libc++)
+ astyle PRIVATE -W -Wall -fno-rtti -fno-exceptions -std=c++11)
elseif(NOT WIN32) # Linux
target_compile_options(astyle PRIVATE -Wall -fno-rtti -fno-exceptions -std=c++11)