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 @@ -38,7 +38,7 @@ # and the Java Development Kit 'include' directories added if(BUILD_JAVA_LIBS) set(BUILD_SHARED_LIBS ON) - if(WIN32) + if(WIN32 OR APPLE) set(java_home $ENV{JAVA_HOME}) if(NOT java_home) message(FATAL_ERROR "Environment variable JAVA_HOME not defined") @@ -58,7 +58,7 @@ if(BUILD_SHARED_LIBS OR BUILD_STATIC_LIBS) add_library(astyle ${SRCS}) if(NOT WIN32) - install(TARGETS astyle DESTINATION /usr/lib) + install(TARGETS astyle DESTINATION lib) endif() else() add_executable(astyle ${SRCS}) @@ -71,8 +71,8 @@ install(TARGETS astyle DESTINATION ${prog_files}/AStyle) install(FILES ${DOCS} DESTINATION ${prog_files}/AStyle/doc/) else() - 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) endif() endif() @@ -83,6 +83,9 @@ if(WIN32) target_include_directories(astyle PRIVATE $ENV{JAVA_HOME}/include) target_include_directories(astyle PRIVATE $ENV{JAVA_HOME}/include/win32) + elseif(APPLE) + target_include_directories(astyle PRIVATE $ENV{JAVA_HOME}/include) + target_include_directories(astyle PRIVATE $ENV{JAVA_HOME}/include/darwin) else() target_include_directories(astyle PRIVATE /usr/lib/jvm/default-java/include) target_include_directories(astyle PRIVATE /usr/lib/jvm/default-java/include/linux) @@ -123,7 +126,7 @@ 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}") @@ -146,7 +149,7 @@ # Set default compile options for supported compilers if(APPLE) target_compile_options( - astyle PRIVATE -W -Wall -fno-rtti -fno-exceptions -std=c++11 -stdlib=libc++) + astyle PRIVATE -W -Wall -fno-rtti -fno-exceptions -std=c++11) set_linker_options("") elseif(NOT WIN32) # Linux target_compile_options(astyle PRIVATE -Wall -fno-rtti -fno-exceptions -std=c++11)