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

Don't automatically install libraries and headers if included as subproject. #3

Merged
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
8 changes: 6 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
cmake_minimum_required(VERSION 3.20)
cmake_minimum_required(VERSION 3.21)
cmake_policy(SET CMP0127 NEW) # <depends> syntax in cmake_dependent_option() is properly formatted for both old and new behavior.

set(LANGUAGES C)
if(BUILD_TESTING)
Expand All @@ -11,10 +12,11 @@ set(CMAKE_POSITION_INDEPENDENT_CODE ON)

set(PROJECTM_EVAL_FLOAT_SIZE "8" CACHE STRING "Byte size of floating-point numbers. 8 to use double, 4 to use float. Default is 8.")

include(CMakeDependentOption)

option(ENABLE_FAST_MATH "Enables aggressive math optimizations like -ffast-math to compile faster code. Applied to Release and RelWithDebInfo configurations only." ON)
option(BUILD_NS_EEL_SHIM "Build and install the ns-eel2 compatibility API shim." OFF)
option(BUILD_BENCHMARKS "Build benchmarks. Requires Google Benchmark." OFF)

if(NOT PROJECTM_EVAL_FLOAT_SIZE EQUAL 8 AND NOT PROJECTM_EVAL_FLOAT_SIZE EQUAL 4)
message(FATAL_ERROR "PROJECTM_EVAL_FLOAT_SIZE must be set to either 4 (use floats) or 8 (use doubles).")
endif()
Expand All @@ -24,6 +26,8 @@ project(projectm-eval
LANGUAGES ${LANGUAGES} # Using "enable_language(CXX)" in the test dir will NOT work properly!
)

cmake_dependent_option(ENABLE_PROJECTM_EVAL_INSTALL "Enable installing projectm-eval libraries and headers." OFF "NOT projectm-eval_IS_TOP_LEVEL" ON)

list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")

include(GNUInstallDirs)
Expand Down
98 changes: 51 additions & 47 deletions ns-eel2-shim/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,65 +1,69 @@
add_library(projectM_ns-eel2 STATIC
ns-eel.c
ns-eel.h
)
ns-eel.c
ns-eel.h
)

target_compile_definitions(projectM_ns-eel2
PUBLIC
EEL_F_SIZE=${PROJECTM_EVAL_FLOAT_SIZE}
)
PUBLIC
EEL_F_SIZE=${PROJECTM_EVAL_FLOAT_SIZE}
)

target_include_directories(projectM_ns-eel2
PUBLIC
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}>
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/projectm-eel>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/projectm-eval/ns-eel2>
)
PUBLIC
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}>
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/projectm-eel>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/projectm-eval/ns-eel2>
)

target_link_libraries(projectM_ns-eel2
PUBLIC
projectM::Eval
)
PUBLIC
projectM::Eval
)

set_target_properties(projectM_ns-eel2 PROPERTIES
EXPORT_NAME ns-eel2
)
EXPORT_NAME ns-eel2
)

add_library(projectM::ns-eel2 ALIAS projectM_ns-eel2)

install(TARGETS projectM_ns-eel2
DESTINATION ${CMAKE_INSTALL_LIBDIR}
EXPORT projectM-EvalMilkdrop
)
if(ENABLE_PROJECTM_EVAL_INSTALL)

install(FILES ns-eel.h
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/projectm-eval/ns-eel2
)
install(TARGETS projectM_ns-eel2
DESTINATION ${CMAKE_INSTALL_LIBDIR}
EXPORT projectM-EvalMilkdrop
)

# For use from an installed package (system install, vcpkg, homebrew etc.)
include(CMakePackageConfigHelpers)
install(FILES ns-eel.h
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/projectm-eval/ns-eel2
)

write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/projectM-EvalMilkdrop/projectM-EvalMilkdropConfigVersion.cmake"
VERSION ${PROJECT_VERSION}
COMPATIBILITY AnyNewerVersion
)
# For use from an installed package (system install, vcpkg, homebrew etc.)
include(CMakePackageConfigHelpers)

configure_package_config_file(projectM-EvalMilkdropConfig.cmake.in
"${CMAKE_CURRENT_BINARY_DIR}/projectM-EvalMilkdrop/projectM-EvalMilkdropConfig.cmake"
INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/projectM-EvalMilkdrop"
PATH_VARS CMAKE_INSTALL_LIBDIR CMAKE_INSTALL_INCLUDEDIR
)
write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/projectM-EvalMilkdrop/projectM-EvalMilkdropConfigVersion.cmake"
VERSION ${PROJECT_VERSION}
COMPATIBILITY AnyNewerVersion
)

install(FILES
"${CMAKE_CURRENT_BINARY_DIR}/projectM-EvalMilkdrop/projectM-EvalMilkdropConfigVersion.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/projectM-EvalMilkdrop/projectM-EvalMilkdropConfig.cmake"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/projectM-EvalMilkdrop"
COMPONENT Devel
)
configure_package_config_file(projectM-EvalMilkdropConfig.cmake.in
"${CMAKE_CURRENT_BINARY_DIR}/projectM-EvalMilkdrop/projectM-EvalMilkdropConfig.cmake"
INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/projectM-EvalMilkdrop"
PATH_VARS CMAKE_INSTALL_LIBDIR CMAKE_INSTALL_INCLUDEDIR
)

install(EXPORT projectM-EvalMilkdrop
FILE projectM-EvalMilkdropTargets.cmake
NAMESPACE projectM::
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/projectM-EvalMilkdrop"
COMPONENT Devel
)
install(FILES
"${CMAKE_CURRENT_BINARY_DIR}/projectM-EvalMilkdrop/projectM-EvalMilkdropConfigVersion.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/projectM-EvalMilkdrop/projectM-EvalMilkdropConfig.cmake"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/projectM-EvalMilkdrop"
COMPONENT Devel
)

install(EXPORT projectM-EvalMilkdrop
FILE projectM-EvalMilkdropTargets.cmake
NAMESPACE projectM::
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/projectM-EvalMilkdrop"
COMPONENT Devel
)

endif()
208 changes: 106 additions & 102 deletions projectm-eval/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,127 +1,131 @@

set(BISON_OUTPUT_FILES
${CMAKE_CURRENT_SOURCE_DIR}/Compiler.c
${CMAKE_CURRENT_SOURCE_DIR}/Compiler.h
)
${CMAKE_CURRENT_SOURCE_DIR}/Compiler.c
${CMAKE_CURRENT_SOURCE_DIR}/Compiler.h
)

set(FLEX_OUTPUT_FILES
${CMAKE_CURRENT_SOURCE_DIR}/Scanner.c
${CMAKE_CURRENT_SOURCE_DIR}/Scanner.h
)
${CMAKE_CURRENT_SOURCE_DIR}/Scanner.c
${CMAKE_CURRENT_SOURCE_DIR}/Scanner.h
)

if (FLEX_FOUND)
if(FLEX_FOUND)
# Generate lexer code
add_custom_command(COMMAND ${FLEX_EXECUTABLE}
--noline
--prefix=prjm_eval_
--header-file=Scanner.h
-o Scanner.c
Scanner.l
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
OUTPUT ${FLEX_OUTPUT_FILES}
DEPENDS Scanner.l
)
--noline
--prefix=prjm_eval_
--header-file=Scanner.h
-o Scanner.c
Scanner.l
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
OUTPUT ${FLEX_OUTPUT_FILES}
DEPENDS Scanner.l
)

add_custom_target(GenerateScanner ALL
DEPENDS ${FLEX_OUTPUT_FILES}
)
endif ()
DEPENDS ${FLEX_OUTPUT_FILES}
)
endif()

if (BISON_FOUND)
if(BISON_FOUND)
# Generate compiler code
add_custom_command(COMMAND ${BISON_EXECUTABLE}
--defines=Compiler.h
-Wcounterexamples
--no-lines
-o Compiler.c
Compiler.y
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
OUTPUT ${BISON_OUTPUT_FILES}
DEPENDS Compiler.y
)
--defines=Compiler.h
-Wcounterexamples
--no-lines
-o Compiler.c
Compiler.y
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
OUTPUT ${BISON_OUTPUT_FILES}
DEPENDS Compiler.y
)

add_custom_target(GenerateCompiler ALL
DEPENDS ${BISON_OUTPUT_FILES}
)
endif ()
DEPENDS ${BISON_OUTPUT_FILES}
)
endif()

add_library(projectM_eval STATIC
${BISON_OUTPUT_FILES}
${FLEX_OUTPUT_FILES}
CompileContext.c
CompileContext.h
Compiler.y
CompilerFunctions.c
CompilerFunctions.h
CompilerTypes.h
ExpressionTree.c
ExpressionTree.h
MemoryBuffer.c
MemoryBuffer.h
Scanner.l
TreeFunctions.c
TreeFunctions.h
TreeVariables.c
TreeVariables.h
api/projectm-eval.c
api/projectm-eval.h
)
${BISON_OUTPUT_FILES}
${FLEX_OUTPUT_FILES}
CompileContext.c
CompileContext.h
Compiler.y
CompilerFunctions.c
CompilerFunctions.h
CompilerTypes.h
ExpressionTree.c
ExpressionTree.h
MemoryBuffer.c
MemoryBuffer.h
Scanner.l
TreeFunctions.c
TreeFunctions.h
TreeVariables.c
TreeVariables.h
api/projectm-eval.c
api/projectm-eval.h
)

target_include_directories(projectM_eval
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/..>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/api>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/projectm-eval>
)
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/..>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/api>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/projectm-eval>
)

set_target_properties(projectM_eval PROPERTIES
EXPORT_NAME Eval
)
EXPORT_NAME Eval
)

if (NOT NO_MATH_LIB_REQUIRED)
if(NOT NO_MATH_LIB_REQUIRED)
target_link_libraries(projectM_eval
INTERFACE
m
)
endif ()
INTERFACE
m
)
endif()

add_library(projectM::Eval ALIAS projectM_eval)

install(TARGETS projectM_eval
DESTINATION ${CMAKE_INSTALL_LIBDIR}
EXPORT projectM-Eval
)

install(FILES api/projectm-eval.h
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/projectm-eval/
)


# For use from an installed package (system install, vcpkg, homebrew etc.)
include(CMakePackageConfigHelpers)

write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/projectM-Eval/projectM-EvalConfigVersion.cmake"
VERSION ${PROJECT_VERSION}
COMPATIBILITY AnyNewerVersion
)

configure_package_config_file(projectM-EvalConfig.cmake.in
"${CMAKE_CURRENT_BINARY_DIR}/projectM-Eval/projectM-EvalConfig.cmake"
INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/projectM-Eval"
PATH_VARS CMAKE_INSTALL_LIBDIR CMAKE_INSTALL_INCLUDEDIR
)

install(FILES
"${CMAKE_CURRENT_BINARY_DIR}/projectM-Eval/projectM-EvalConfigVersion.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/projectM-Eval/projectM-EvalConfig.cmake"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/projectM-Eval"
COMPONENT Devel
)

install(EXPORT projectM-Eval
FILE projectM-EvalTargets.cmake
NAMESPACE projectM::
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/projectM-Eval"
COMPONENT Devel
)
if(ENABLE_PROJECTM_EVAL_INSTALL)

install(TARGETS projectM_eval
DESTINATION ${CMAKE_INSTALL_LIBDIR}
EXPORT projectM-Eval
)

install(FILES api/projectm-eval.h
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/projectm-eval/
)


# For use from an installed package (system install, vcpkg, homebrew etc.)
include(CMakePackageConfigHelpers)

write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/projectM-Eval/projectM-EvalConfigVersion.cmake"
VERSION ${PROJECT_VERSION}
COMPATIBILITY AnyNewerVersion
)

configure_package_config_file(projectM-EvalConfig.cmake.in
"${CMAKE_CURRENT_BINARY_DIR}/projectM-Eval/projectM-EvalConfig.cmake"
INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/projectM-Eval"
PATH_VARS CMAKE_INSTALL_LIBDIR CMAKE_INSTALL_INCLUDEDIR
)

install(FILES
"${CMAKE_CURRENT_BINARY_DIR}/projectM-Eval/projectM-EvalConfigVersion.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/projectM-Eval/projectM-EvalConfig.cmake"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/projectM-Eval"
COMPONENT Devel
)

install(EXPORT projectM-Eval
FILE projectM-EvalTargets.cmake
NAMESPACE projectM::
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/projectM-Eval"
COMPONENT Devel
)

endif()
Loading