Browse Source

Add includes to build interface of decaf libs

Apply Modern CMake best practices and use target_include_directories
rather than include_directories for defining where to find header files.
Where possible, scope was reduced to PRIVATE, indicating that the headers
are required only for compilation, not when linking against the target.

Additionally, the generated headers that are required for the decaf libs
to work have been added to their build interface. This means that other
projects that use CMake to build this project will correctly link against
the decaf and decaf-static targets.
master
Marius Volkhart 6 years ago
parent
commit
540d9b8158
8 changed files with 28 additions and 51 deletions
  1. +0
    -7
      CMakeLists.txt
  2. +8
    -6
      src/CMakeLists.txt
  3. +2
    -8
      src/curve25519/CMakeLists.txt
  4. +2
    -8
      src/ed448goldilocks/CMakeLists.txt
  5. +1
    -5
      src/generator/curve25519/CMakeLists.txt
  6. +1
    -5
      src/generator/ed448goldilocks/CMakeLists.txt
  7. +7
    -6
      src/p25519/CMakeLists.txt
  8. +7
    -6
      src/p448/CMakeLists.txt

+ 0
- 7
CMakeLists.txt View File

@@ -34,13 +34,6 @@ include(GNUInstallDirs)
include(CheckSymbolExists)
include(CMakePushCheckState)

include_directories(
${GSOURCE_PATH}/include/
src/include/
src/
${CMAKE_CURRENT_BINARY_DIR}
)

set(STRICT_OPTIONS_CPP )
set(STRICT_OPTIONS_C )
set(STRICT_OPTIONS_CXX )


+ 8
- 6
src/CMakeLists.txt View File

@@ -61,10 +61,6 @@ else() # nothing picked yet, stick to the
message("Target architecture is general purpose 32bits")
endif()

include_directories(
${PROJECT_SOURCE_DIR}/src/include/${TARGET_ARCH_DIR}
)

set(DECAF_SOURCE_FILES_CXX
)

@@ -79,7 +75,10 @@ if(ENABLE_STATIC)
add_library(decaf-static STATIC ${DECAF_HEADER_FILES} ${DECAF_SOURCE_FILES_C} ${DECAF_SOURCE_FILES_CXX} $<TARGET_OBJECTS:p25519> $<TARGET_OBJECTS:p448> $<TARGET_OBJECTS:CURVE25519> $<TARGET_OBJECTS:CURVE448>)
add_dependencies(decaf-static generatedCode)
set_target_properties(decaf-static PROPERTIES OUTPUT_NAME decaf)
target_include_directories(decaf-static PUBLIC)
target_include_directories(decaf-static
PUBLIC $<BUILD_INTERFACE:${GSOURCE_PATH}/include>
PRIVATE ${PROJECT_SOURCE_DIR}/src/include
)
target_link_libraries(decaf-static INTERFACE)
endif()
if(ENABLE_SHARED)
@@ -89,7 +88,10 @@ if(ENABLE_SHARED)
set_target_properties(decaf PROPERTIES LINK_FLAGS "-stdlib=libc++")
endif()
set_target_properties(decaf PROPERTIES VERSION ${DECAF_SO_VERSION})
target_include_directories(decaf PUBLIC)
target_include_directories(decaf
PUBLIC $<BUILD_INTERFACE:${GSOURCE_PATH}/include>
PRIVATE ${PROJECT_SOURCE_DIR}/src/include
)
target_link_libraries(decaf PRIVATE)
if(MSVC)
if(CMAKE_BUILD_TYPE STREQUAL "Debug" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")


+ 2
- 8
src/curve25519/CMakeLists.txt View File

@@ -4,13 +4,6 @@
# Released under the MIT License. See LICENSE.txt for license information.
#
############################################################################

include_directories(
${PROJECT_SOURCE_DIR}/src/p25519
${GSOURCE_PATH}/c/p25519
${PROJECT_SOURCE_DIR}/src/p25519/${TARGET_ARCH_DIR_P25519}
)

set(CURVE25519_SOURCE_FILES_C
${GSOURCE_PATH}/c/curve25519/decaf.c
${GSOURCE_PATH}/c/curve25519/elligator.c
@@ -26,5 +19,6 @@ SET_SOURCE_FILES_PROPERTIES(${GSOURCE_PATH}/c/curve25519/eddsa.c PROPERTIES GENE
SET_SOURCE_FILES_PROPERTIES(${PROJECT_SOURCE_DIR}/src/curve25519/decaf_tables.c PROPERTIES GENERATED 1)

add_library(CURVE25519 OBJECT ${CURVE25519_SOURCE_FILES_C})
add_dependencies(CURVE25519 generatedCode p25519)
add_dependencies(CURVE25519 generatedCode)
target_link_libraries(CURVE25519 PRIVATE p25519)
set_target_properties(CURVE25519 PROPERTIES POSITION_INDEPENDENT_CODE True)

+ 2
- 8
src/ed448goldilocks/CMakeLists.txt View File

@@ -4,13 +4,6 @@
# Released under the MIT License. See LICENSE.txt for license information.
#
############################################################################

include_directories(
${PROJECT_SOURCE_DIR}/src/p448
${GSOURCE_PATH}/c/p448
${PROJECT_SOURCE_DIR}/src/p448/${TARGET_ARCH_DIR_P448}
)

set(CURVE448_SOURCE_FILES_C
${GSOURCE_PATH}/c/ed448goldilocks/decaf.c
${GSOURCE_PATH}/c/ed448goldilocks/elligator.c
@@ -26,5 +19,6 @@ SET_SOURCE_FILES_PROPERTIES(${GSOURCE_PATH}/c/ed448goldilocks/eddsa.c PROPERTIES
SET_SOURCE_FILES_PROPERTIES(${PROJECT_SOURCE_DIR}/src/ed448goldilocks/decaf_tables.c PROPERTIES GENERATED 1)

add_library(CURVE448 OBJECT ${CURVE448_SOURCE_FILES_C})
add_dependencies(CURVE448 generatedCode p448)
add_dependencies(CURVE448 generatedCode)
target_link_libraries(CURVE448 PRIVATE p448)
set_target_properties(CURVE448 PROPERTIES POSITION_INDEPENDENT_CODE True)

+ 1
- 5
src/generator/curve25519/CMakeLists.txt View File

@@ -84,17 +84,13 @@ add_custom_target(generatorCurve25519 DEPENDS
${GSOURCE_PATH}/include/decaf/point_255.hxx
${GSOURCE_PATH}/include/decaf/ed255.hxx
)
include_directories(
${PROJECT_SOURCE_DIR}/src/p25519
${GSOURCE_PATH}/c/p25519
${PROJECT_SOURCE_DIR}/src/p25519/${TARGET_ARCH_DIR_P25519}
)

add_executable(decaf_gen_tables_curve25519 EXCLUDE_FROM_ALL ${GSOURCE_PATH}/c/curve25519/decaf_gen_tables.c
${GSOURCE_PATH}/c/curve25519/decaf.c
${GSOURCE_PATH}/c/curve25519/scalar.c
${PROJECT_SOURCE_DIR}/src/utils.c
$<TARGET_OBJECTS:p25519>)
target_link_libraries(decaf_gen_tables_curve25519 PRIVATE p25519)

add_custom_target(decaf_tables_curve25519
COMMAND decaf_gen_tables_curve25519 > ${PROJECT_SOURCE_DIR}/src/curve25519/decaf_tables.c


+ 1
- 5
src/generator/ed448goldilocks/CMakeLists.txt View File

@@ -92,17 +92,13 @@ add_custom_target(generatorEd448goldilocks DEPENDS
${GSOURCE_PATH}/include/decaf/point_448.hxx
${GSOURCE_PATH}/include/decaf/ed448.hxx
)
include_directories(
${PROJECT_SOURCE_DIR}/src/p448
${GSOURCE_PATH}/c/p448
${PROJECT_SOURCE_DIR}/src/p448/${TARGET_ARCH_DIR_P448}
)

add_executable(decaf_gen_tables_ed448goldilocks EXCLUDE_FROM_ALL ${GSOURCE_PATH}/c/ed448goldilocks/decaf_gen_tables.c
${GSOURCE_PATH}/c/ed448goldilocks/decaf.c
${GSOURCE_PATH}/c/ed448goldilocks/scalar.c
${PROJECT_SOURCE_DIR}/src/utils.c
$<TARGET_OBJECTS:p448>)
target_link_libraries(decaf_gen_tables_ed448goldilocks PRIVATE p448)

add_custom_target(decaf_tables_ed448goldilocks
COMMAND decaf_gen_tables_ed448goldilocks > ${PROJECT_SOURCE_DIR}/src/ed448goldilocks/decaf_tables.c


+ 7
- 6
src/p25519/CMakeLists.txt View File

@@ -4,12 +4,6 @@
# Released under the MIT License. See LICENSE.txt for license information.
#
############################################################################
include_directories(
${PROJECT_SOURCE_DIR}/src/p25519
${GSOURCE_PATH}/c/p25519
${PROJECT_SOURCE_DIR}/src/p25519/${TARGET_ARCH_DIR_P25519}
)

set(P25519_HEADER_FILES
${GSOURCE_PATH}/c/p25519/f_field.h
${TARGET_ARCH_DIR_P25519}/f_impl.h
@@ -25,5 +19,12 @@ SET_SOURCE_FILES_PROPERTIES(${GSOURCE_PATH}/c/p25519/f_generic.c PROPERTIES GENE

add_library(p25519 OBJECT ${P25519_HEADER_FILES} ${P25519_SOURCE_FILES_C})
add_dependencies(p25519 generatorP25519)
target_include_directories(p25519
PUBLIC ${GSOURCE_PATH}/include
PUBLIC ${GSOURCE_PATH}/c/p25519
PUBLIC ${TARGET_ARCH_DIR_P25519}
PUBLIC ${PROJECT_SOURCE_DIR}/src/include/${TARGET_ARCH_DIR}
PUBLIC ${PROJECT_SOURCE_DIR}/src/include
)

set_target_properties(p25519 PROPERTIES POSITION_INDEPENDENT_CODE True)

+ 7
- 6
src/p448/CMakeLists.txt View File

@@ -4,12 +4,6 @@
# Released under the MIT License. See LICENSE.txt for license information.
#
############################################################################
include_directories(
${PROJECT_SOURCE_DIR}/src/p448
${GSOURCE_PATH}/c/p448
${PROJECT_SOURCE_DIR}/src/p448/${TARGET_ARCH_DIR_P448}
)

set(P448_HEADER_FILES
${GSOURCE_PATH}/c/p448/f_field.h
${TARGET_ARCH_DIR_P448}/f_impl.h
@@ -25,5 +19,12 @@ SET_SOURCE_FILES_PROPERTIES(${GSOURCE_PATH}/c/p448/f_generic.c PROPERTIES GENERA

add_library(p448 OBJECT ${P448_HEADER_FILES} ${P448_SOURCE_FILES_C})
add_dependencies(p448 generatorP448)
target_include_directories(p448
PUBLIC ${GSOURCE_PATH}/include
PUBLIC ${GSOURCE_PATH}/c/p448
PUBLIC ${TARGET_ARCH_DIR_P448}
PUBLIC ${PROJECT_SOURCE_DIR}/src/include/${TARGET_ARCH_DIR}
PUBLIC ${PROJECT_SOURCE_DIR}/src/include
)

set_target_properties(p448 PROPERTIES POSITION_INDEPENDENT_CODE True)

Loading…
Cancel
Save